Skip to content

Instantly share code, notes, and snippets.

@walterdavis
Forked from Mr2P/gist:3081898
Created September 18, 2012 21:21
Show Gist options
  • Save walterdavis/3745984 to your computer and use it in GitHub Desktop.
Save walterdavis/3745984 to your computer and use it in GitHub Desktop.
background size cover polyfill for IE (6, 7, 8)
if ("backgroundSize" in document.body.style) {
return;
}
var body = $$('body').first(),
img = body.getStyle('background-image').sub(/url\((.+?)\)/,'#{1}') || 'default.jpeg',
fill = new Element('img', {src: img,alt: ''}).
setStyle('position:absolute; top:0; left:0; width:100%; height:100%; z-index:-1');
body.setStyle('background:none');
body.insert(fill);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment