I have a link (a
element) with an image (img
element) inside. I'm trying to make the parent element (a
element) the same width as its child, which has a width of 75%.
I made the link to display: inline-block
, just like this answer says to do, but it's not working. The parent element is still larger than its child. What am I doing wrong, and how can I fix it?
#img-link {
display: inline-block;
background-color: lightblue;
}
#img {
width: 75%;
}
<a href="#" id="img-link">
<img src="http://i.imgur.com/VROQLTe.jpg" id="img">
</a>