Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

100% width image, keep ratio with min-height

Tags:

css

I want an image to be 100% BUT have a min-height of 500px when the image reaches this height I want the ratio to stay (basically) turn off 100% width. I know this is possible with javascript but I've never seen it done with css. Is it possible?

like image 896
ThomasReggi Avatar asked Oct 21 '22 12:10

ThomasReggi


1 Answers

html

<img src="/path.jpg" />

CSS

img { min-height: 500px; }

notice

Just ensure you had not defined width for this image in element or in css for upper elements. If everything is ok -- image would be scaled to min-height keeping ratio.

And keep in mind to use larger images then your min-height -- otherwise it would be ugly.

like image 96
Eugene Kaurov Avatar answered Nov 11 '22 06:11

Eugene Kaurov