IE 10 & 11 make fixed backgrounds jump when scrolling with mouse wheel [closed]

眉间皱痕 提交于 2019-11-27 18:27:39

I know it is a bit late for an answer but I've had the same problem and was able to fix it by adding these attributes to my css file

html{
    overflow: hidden;
    height: 100%;    
}
body{
    overflow: auto;
    height: 100%;
}

From the comments:

This solution stops scroll events from firing on the window, so do be careful if you're using anything that relies on such events firing. codepen.io/anon/pen/VawZEV?editors=1111 ( overflow: hidden, scroll events don't work) codepen.io/anon/pen/PNoYXY?editors=1111 ( overflow: auto, scroll events fire) - Dan Abrey

So this might cause some problems in your projects. But I don't see another way to workaround this bug in IE.

uniquelau

This looks like a z-index bug, try adding z-index: 1.

Looking into this, I've found the best way to debug is to:

Create a simple element at the top of the page, e.g.

 <style>#test {position: fixed; background: red; top: 0; left: 0; width: 4em}</style>
 <div id="test">Test</div>

In all the above cases, this works correctly, and the scroll is smooth. So this proves it can be done! Now slowly add your properties back in, until you are able to get the element with position fixed to work in the context of your site.

I then found that adding a z-index to the fixed items resolved the issue. (e.g. z-index: 1)

I also discovered that once a position is set on a child element, the bug presents it's self from that point down/onwards. So you need to ensure none of the child elements have a position set, or if they do, you explicitly set a position on each child.

E.g.

<!-- Works -->
<div style="position: fixed;">
    <div>Nice</div>
    <div>Wicked</div>
    <div>Cool</div>
</div>

<!-- Element with position: relative, experiences the bug -->
<div style="position: fixed;">
    <div style="position: relative;">sad</div>
    <div>sad</div>
    <div style="position: fixed;">happy</div>
</div>

It's fixable, but will require some tweaking!

Here is a workaround (tested on Windows 8.1):

Move the "background" CSS property to the BODY element. Currently it is on the DIV element with id="filler". Here is the resulting CSS:

    body {
        font-family: Helvetica, Arial, sans-serif;
        background: #fff url(blue-kitty.jpg) no-repeat fixed center 100px;
    }

    #filler {
        text-align: center;
    }

    .big-margin {
        margin-top: 500px;
    }

try to turn off smooth scrolling option.

Internet Options - Advenced Tab - Use Smooth Scrolling

it's like rendering bug.... MS IE team is investigating....

The fix in my case was to simply remove the z-index property from the element that has position:fixed, IE then stopped the strange flickering.

(disabling smooth scrolling on IE options worked while having he z-index property but that's not a solution since users would most likely have it on by default).

just simply define body container to relative.

<style>
    body
    {
        position: relative;
    }
</style>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!