Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IE background size not working

I'm trying to make a background stretch the entire body (width only). This works only on Chrome,Opera and Firefox. How can I make this work on IE too? O_o

background-size:100%;
-moz-background-size: auto 100%;
-o-background-size: auto 100%;
like image 836
XCS Avatar asked Jan 26 '11 15:01

XCS


2 Answers

I created jquery.backgroundSize.js: a 1.5K jquery plugin that can be used as a IE8 fallback for "cover" and "contain" values. Have a look at the demo.

like image 172
Louis-Rémi Avatar answered Sep 27 '22 02:09

Louis-Rémi


since background-size is CSS3 specific your gonna have to use something like this for it to work in IE

set your html and body to

html {overflow-y:hidden}
body {overflow-y:auto}

wrap the image you want fullscreened with a div #page-background

#page-background {position:absolute; z-index:-1}

then put this in your html file

<div id="page-background">
  <img src="/path/to/your/image" width="100%" height="100%">
</div>

** you will have to use some sort of reset to remove the margins and paddings, something like this

html, body {height:100%; margin:0; padding:0;}
like image 23
daniel Avatar answered Sep 26 '22 02:09

daniel