Skip to content

Instantly share code, notes, and snippets.

@walterdavis
Created December 4, 2012 21:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walterdavis/4208778 to your computer and use it in GitHub Desktop.
Save walterdavis/4208778 to your computer and use it in GitHub Desktop.
if (!('backgroundSize' in document.body.style)) {
var body = $$('body').first(),
img = body.getStyle('background-image').sub(/url\("?(.+?)"?\)/,'#{1}') || 'default.jpeg';
body.setStyle('background:#ccc');
var fill = new Element('img', {
src: img,
alt: ''
}).setStyle('position:absolute; top:0; left:0; min-width: 100%; height: ' + ($(document.body).getHeight() + 80) + 'px; z-index:-1');
body.insert({top: fill});
Event.observe(window, 'load', function(){
fill.setStyle('height:' + ($(document.body).getHeight() + 80) + 'px');
});
Event.observe(window, 'resize', function(){
fill.setStyle('height:' + ($(document.body).getHeight() + 80) + 'px');
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment