So I have some parent container/div positioned 'fixed' on the page. It's height and width are set to 100%. Within the container is an image. I currently have written some JavaScript so that the image stretches either to 100% width or 100% height of the container, depending on the image's dimensions. The image is then vertically or horizontally centered. As well, this is done every time the window is re-sized so that the image is always centered and fits.
Currently this is working wonderfully, but ... this is besides the point. The real question is this: Is there a way of doing this with just CSS? In other words, is it possible for an element to stretch proportionally to it's container but not be clipped/cut-off and doing so with JUST CSS? Also, NOT background-size: contain
. Hacks are also welcome. Thanks.
I set up a fiddle for anyone that wants to mess around... HERE.
EDIT
Just in case someone out there on the interwebs is looking...
A viable alternative to using an <img>
can be the CSS background-size
property. Browser compatibility and more info from the Mozilla Developer Network HERE