Home › Forums › CSS › how to fully stretch background image that works in IE?? › Re: how to fully stretch background image that works in IE??
December 5, 2012 at 6:01 am
#116362
Member
In modern browsers you can now use the CSS3 property background-size
.selector {
/* will stretch the image so that it covers all of the element */
background-size: cover;
/* will stretch the image so that it fits perfectly inside the element */
background-size: contain;
}
This allows to achieve background stretching while preserving the aspect ratio of the background-image: https://developer.mozilla.org/en-US/docs/CSS/background-size
I’ve personally developed a polyfill that implements those properties in IE8: https://github.com/louisremi/background-size-polyfill