Stretch a background image in IE8

前端 未结 7 799
时光说笑
时光说笑 2020-12-14 13:29

I\'m trying to stretch a background image to 100% width and height of the parent div. background-size is not supported in IE8 of-course. I tried the following code but it\'s

7条回答
  •  失恋的感觉
    2020-12-14 13:44

    Use a with position:fixed;top:0;left:0;width:100%;height:100%; and negative z-index. There's unfortunately no way to implement this behavior in IE 8 using only CSS.

    See the following article for further information: How Do you Stretch a Background Image in a Web Page.

    If you wish to use an image as a background for a given

    try the following approach:

    .fullbackground{
        position:relative;
    }
    img.fullbackground{
        position:absolute;
        z-index:-1;
        top:0;
        left:0;
        width:100%; /* alternative: right:0; */
        height:100%; /* alternative: bottom:0; */
    }
    

提交回复
热议问题