This is like the background-size: contain
property but I'm trying to do it with <img>
. Is there any way to replicate it?
Asked
Active
Viewed 53 times
0

antyrat
- 27,479
- 9
- 75
- 76

themostenjoyableday
- 25
- 1
- 5
-
`width: 100%; height: 100%` or do you mean something else specifically? – JiFus Feb 27 '15 at 18:17
-
1@JiFus: that doesn't maintain the aspect ratio. – Ulrich Schwarz Feb 27 '15 at 18:18
-
Well now I see what you mean. Then set the smallest (width/height) to 100% ? – JiFus Feb 27 '15 at 18:20
-
1Check this out: http://stackoverflow.com/questions/11670874/is-there-an-equivalent-to-background-size-cover-and-contain-for-image-elements – dowomenfart Feb 27 '15 at 18:20
-
If you want to just use css, see http://stackoverflow.com/questions/10858994/css-media-query-height-greater-than-width-and-visa-versa-or-how-to-imitate-with – Radio Feb 27 '15 at 18:20
-
oh disregard, I misunderstood the question. JS is the way to go. – Radio Feb 27 '15 at 18:21