Why does a fixed background-image move when scrolling on IE?

前端 未结 11 1382
时光取名叫无心
时光取名叫无心 2020-12-29 06:37

I\'m trying to make background-image fixed.

As you see in my blog, the background-image is moving when scrolling on IE 11.

How can

11条回答
  •  春和景丽
    2020-12-29 07:11

    My final fix is based on all the answers I've found:

    On the main css for Edge / ie11 / ie10

    /*Edge*/
    @supports ( -ms-accelerator:true ) 
    {
        html{
            overflow: hidden;
            height: 100%;    
        }
        body{
            overflow: auto;
            height: 100%;
        }
    }
    /*Ie 10/11*/
    @media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) 
    {
        html{
            overflow: hidden;
            height: 100%;    
        }
        body{
            overflow: auto;
            height: 100%;
        }
    }
    

    For ie9, ie8 and ie7 I've added the code (without media query) in a separate hacksheet:

    
    

提交回复
热议问题