pee2pee pee2pee - 1 month ago 7
CSS Question

Image to Fit Containing Div

I have done this many times before but it doesn't seem to work now for whatever reason. I want the image to be the full the width of the container but it doesn't. Any ideas?

jsFiddle: http://jsfiddle.net/Lqffk1ak/

Code:



img {
max-width: 100%;
max-height: 100%;
}
div {
background: #ccc;
}

<div>
<img src="https://s11.postimg.org/dpgqru2pv/Police2_600x250.jpg" class="full-width">
</div>




Answer

Just add width:100% to img

img {
    width:100%
}
Comments