html - Expand image inside DIV -


How can I raise an image to keep the same height as the div after resizing? Or how can I fill the white space left with color in the image?

I think this will get you the desired result:

  & Lt; Style & gt; Div {Width: 50px; Height: 100px; } Div img {height: 100%; } & Lt; / Style & gt; & Lt; Div & gt; & Lt; Img src = 'path / to / img.gif' / & gt; & Lt; / Div & gt;  

The image will then be filled to the height of the container divis and it will scale its width with its aspect ratio. This allows the image to be expanded before the desired width of the box, although be careful.


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -