Background-size 100% not working in IE8 and IE7

后端 未结 2 2007
北海茫月
北海茫月 2021-01-21 07:03

I have an empty div which contain a background image that is bigger than the size of the container. I fix this one by background-image property with the value (100%

2条回答
  •  花落未央
    2021-01-21 07:30

    since background-size is CSS3 specific which is not supported to IE you have to do 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

    ** 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;}
    

提交回复
热议问题