fixed positioned element flicker in IE only, how to solve?
Asked Answered
W

8

13

Weird problem in IE11, the fixed background of the following project flickers when using mousewheel or cursor keys only. This is a bug, for sure.

website: http://gerbrandy.zitemedia.nl:88/

I use a script to resize the background proportional but this is not the problem because the resize event does not fire when scrolling, so it is not a problem of the script. It has something to do with a fixed positioned element. This script works okay for several years in all other browsers.

I have no idea how to fix this. Tried several things, but don't know how to disable javascript for example but should not be the case. I'm using IE11 on Windows 8.1.

Does somebody has some same experience with this and do you know how to work around this problem?

Watters answered 8/1, 2014 at 12:19 Comment(8)
Seems to work for me using IE11 on Win 7 (64). Is this possibly specific to a version of Windows (7 / 8 / 8.1 - Modern or desktop)?Redeem
Hai Nigel, thanks for testing. Well, i'm using Windows 8.1 Dutch version but doesn't sound that special i think? I have not tested it on Win7.Watters
Are you using the Modern/Touch interface or the desktop interface as these sometimes render differently?Redeem
@Nigel, no i'am not using the terrible interface of Windows 8. I use Windows 8 without the new GUI as much as possible.Watters
That's a relief :) I'm at work at the moment so only have a Windows 7 machine. Maybe someone else can compare Windows 7 and Windows 8 IE11s to see if there is a difference.Redeem
I have also test in on Win7 with IE11 and it is working fine.Watters
For me, the jumpy behavior was caused by opacity:0.99 on the HTML element (a fix for bolder fonts on Mac).Jacquiline
css question in my opinion, not js. just nitpick, useful question since I have found the answer to my same issue here.Uteutensil
A
19

Three things can cause IE 11 flickering/choppy/delay for fixed position element while scrolling:

  1. If you have an "overflow: auto;" on the parent container element, remove it.

  2. Remove background-attachment:fixed; from the fixed position element.

  3. Remove border-radius from the fixed position element (mobile IE only).

Affirmative answered 29/12, 2014 at 22:52 Comment(8)
The overflow sorted this for me. I move my element out of the containing element with overflow:auto; and it worked.Searcy
yep, border-radius caused trouble for me on IE mobileShirberg
Changing to "overflow: visible;" in the parent element did it for me. (it was "overflow: hidden;")Spielman
The border-radius suggestion was golden. Thanks a lot!Kozlowski
I forced the parent to have position: static and that fixed my issue.Chadchadabe
removing background-attachment:fixed worked for me.Underclothing
Note: My parent didn't have an overflow, but my current element did have overflow: auto, which caused this to fail.Comminate
Had to position: static two parents in my case to fix it. Just in case someone wonders why only the direct parent being static might not be enough in their implementation.Uteutensil
A
13

I was having the same issue, it seems to be a bug that occurs when there is too much going on inside the page for your computer specs to handle, I was able to fix it by adding the following transform code to the fixed position element, (transform: translateZ(0);-webkit-transform: translateZ(0);) that forces the browser to use hardware acceleration to access the device’s graphical processing unit (GPU) to make pixels fly. Web applications, on the other hand, run in the context of the browser, which lets the software do most (if not all) of the rendering, resulting in less horsepower for transitions. But the Web has been catching up, and most browser vendors now provide graphical hardware acceleration by means of particular CSS rules.

Using -webkit-transform: translate3d(0,0,0); will kick the GPU into action for the CSS transitions, making them smoother (higher FPS).

Note: translate3d(0,0,0) does nothing in terms of what you see. it moves the object by 0px in x,y and z axis. It's only a technique to force the hardware acceleration.

 #element {
        position: fixed;
        width: 100%;
        left: 0;
        top: 0;
        z-index: 9994;
...other stuff and then
        /* MAGIC HAPPENS HERE */
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }
Abernon answered 18/9, 2014 at 22:55 Comment(1)
This works, but beware of just sticking transforms on any element; it might mess up any child elements with position:fixed. (#2637558)Preconceive
P
7

We can remove grey flicker on IE9, IE10, IE11, MEdge<=20 by setting overflow of html and body like

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

body{
  overflow: auto;
  height: 100%;
}
Palmira answered 27/9, 2018 at 7:14 Comment(0)
C
5

Apparently the "bug" only affects IE11 on Windows 8.1, or maybe 8.0 too. Removing background-attachmend:fixed worked for me. Apparently that rule was redundant, since the background image displays correctly in every browser without that rule. A second solution is to disable Smooth Scrolling in the IE settings, but that's not optimal since it's enabled in a default installation.

Flickering CSS:

#element_id{
    position:fixed;
    height:100%;
    left:0;
    bottom:0;
    right:0;
    background-image:url('path/to/jpg');
    -webkit-background-size:cover;
    -moz-background-size:cover;
    -o-background-size:cover;
    background-size:cover;
    background-repeat:no-repeat;
    background-position:center center;
    background-attachment:fixed;
}

...and new code (1 line removed):

#element_id{
    position:fixed;
    height:100%;
    left:0;
    bottom:0;
    right:0;
    background-image:url('path/to/jpg');
    -webkit-background-size:cover;
    -moz-background-size:cover;
    -o-background-size:cover;
    background-size:cover;
    background-repeat:no-repeat;
    background-position:center center;
}
Cambria answered 9/12, 2014 at 9:36 Comment(1)
Ah, thanks for the solution after all this time. Not working at this suck company (with their suck scripts, CMS and templates) any more so cannot try it. But your solution sounds plausible. I think that background sizing must be a CSS thing and not a script. Also background-size:cover can be a problem on the iPad 1 or 2. You must specify the screen size in pixels instead.Watters
H
3

A hardware acceleration technique as follow caused mine.

outline: 1px solid transparent;

Remove it and it might be the cause.

Haemorrhage answered 5/4, 2016 at 12:54 Comment(4)
Very random, but this worked. It was nested deep in the my fixed position div, but it still caused the entire thing to flicker.Presumptive
to optimize a fixed element use -ms-transform: translateZ(0); this will still optimize it on ie, and you won't see a flicker on Safari.Haemorrhage
I was in the process of trying to get rid of the flicker on chrome, and translateZ(0) solved it. Thanks again! I guess chrome is random too.Presumptive
I had a background video autoplaying and it flickered on "IE Edge". Don't know why this worked but thank you! :)Astromancy
T
1

This behaviour is due to a bug with Microsofts "Smooth Scroll" feature. Happens in IE10 and 11 on Win7 and up. I wouldn't recommend to alter your perfectly working code to fix yet another MS bug. Instead disable their "feature" by opening Internet Explorers Settings, go to Advanced and in the category "Browsing" it's the last option which you need to disable "Use smooth scrolling".

Thagard answered 13/1, 2019 at 20:24 Comment(1)
Aparently there is a more or less working JS solution out there as well.Thagard
B
0

Another reason for flickering can obviously be another fixed element inside the fixed element. At least that was the reason in my case. The false behaviour of Edge appears to be random.

Barefaced answered 11/2, 2018 at 11:34 Comment(0)
C
-1

My Website's body was set to position: relative. Removing that did the trick for my IE-exclusive flickering/jumping problem.

Collyer answered 13/6, 2017 at 22:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.