Hack to size the container of a background image
An element that contains a background image cannot have its height and width derived from that background image. An element can have a height and width that is determined by the size of a child element however. Combine the two to ensure that the container of the background image has the height and width of the image itself.
<div style="background-image: url('http://example.com/image.png')">
<img src="http://example.com/image.png">
</div>
Tweet