8
Use a combination of background images and behavior settings via CSS.
Explanation:
background-size:contain
will force the background image to be contained within the element;background-repeat:no-repeat
will cause the image to appear only once;background-position: center
center the image on both axes, regardless of size or width.
.container {
width:200px;
height:200px;
display:inline-block;
background-size:contain;
background-repeat:no-repeat;
background-position: center;
border:1px solid black;
}
<div class='container' style='background-image:url(https://upload.wikimedia.org/wikipedia/commons/7/72/Wide_view_over_S%C3%B8rfjorden_from_the_coast_of_Sveingard,_2012_June.jpg)'>
</div>
<div class='container' style='background-image:url(http://wvs.topleftpixel.com/photos/scotia_plaza_tall_stitched.jpg)'>
</div>
No javascript? I don’t know if it’s possible ein...
– DontVoteMeDown