My goal is to have an image fill its parent element completely.
<div class="parent">
<img src="image.jpg">
</div>
If I use the following CSS:
img{
width: 100%;
}
The image will only fill the parent horizontally, leaving empty space if it's smaller vertically. See example below:
What I really want is for the image to cover the entire parent element. I don't want to use overflow: hidden because that would cut off an image larger than its parent. I want the image to resize and cover the parent like background-size: cover does for backgrounds, but with regular image elements.
Can anyone help me achieve this?
Thanks!