Reputation: 4428
It looks like the <a>
-tag is visually lying at the bottom of the <img>
-tag:
<a href="https://www.facebook.com/" target="_blank">
<img src="https://www.facebook.com/favicon.ico"/>
</a>
a {
background: #999;
}
a:hover {
background: yellow;
}
img {
height: 32px;
width: 32px;
padding: 8px;
border: 1px solid green;
}
There is a fiddle here: http://jsfiddle.net/lborgman/d2fc1jz5/
Note: Tested in Chrome only.
Upvotes: 1
Views: 56
Reputation: 121
<a> is a inline-block;must make it block first.
a {
background: red;
display:block;
width:32px;
}
a:hover {
background: yellow;
}
img {
height: 32px;
width: 32px; `
}
Upvotes: 0
Reputation: 587
Change your CSS style like this. All I have changed is added display:inline-block to the 'a' selector and vertical-align:top to 'img' selector.
a {
background: #999;
display:inline-block;
}
a:hover {
background: yellow;
}
img {
height: 32px;
width: 32px;
padding: 8px;
border: 1px solid green;
vertical-align:top;
}
Upvotes: 2
Reputation: 338
Try to change your a
in css into this...
a {
background: #999;
height: 50px; /* height + (padding*2) + (border*2) and also the width*/
width: 50px;
position:absolute;
}
Upvotes: 0
Reputation: 2865
Add display:inline-block to your a class like so:
a {
background: #999;
display: inline-block;
}
Upvotes: 3