18

I'm on Chrome 68.

Whenever I have filter: invert(xxx); on the <body>, anything positioned as fixed doesn't stick to the screen, it scrolls with everything.


Demo with filter: invert(xxx);

body{
  height: 8000px;
  filter: invert(0.85);
}

div{
  position: fixed;
  top: 0;
  left: 0;
  height: 100px;
  width: 100px;
  border: 1px solid black;
}
<div></div>


Demo without filter: invert(xxx);

body{
  height: 8000px;
}

div{
  position: fixed;
  top: 0;
  left: 0;
  height: 100px;
  width: 100px;
  border: 1px solid black;
}
<div></div>

EDIT: Works fine on Chrome 67, but not on Chrome 68.

12
  • Interesting bug, i found it on FireFox (61.0.1), only... Commented Jul 30, 2018 at 7:48
  • I'm using Chrome, though. Commented Jul 30, 2018 at 7:49
  • Chrome 67.0.3396.99: working perfectly... Chrome 68.0.3440.75: bug appears... Commented Jul 30, 2018 at 7:50
  • 1
    It seems to be a Chrome 68 bug, I tested it on Chrome 67 and it works fine. I'm adding the tag. Commented Jul 30, 2018 at 7:53
  • 2
    using filter seems to be the issue - also experiencing this with adding dropshadows via filter. filter creates a new position context for children with position: fixed at any sub-body level Commented Aug 23, 2018 at 9:49

1 Answer 1

15

It looks like a bug on Google Chrome 68, but you can solve this using the <html> element instead of the <body> element:

html {
  height: 8000px;
  filter: invert(0.85);
}
div {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  height: 100px;
  width: 100px;
  border: 1px solid black;
}
<div></div>

Note: In case only top and left is set to 0 the element doesn't stay fixed on scroll. But if you add bottom: 0; the element stay fixed again.


I also compared the styles before (Chrome 67) and after (Chrome 68) the update and the following values changed on the same example (with filter):

+---------------+-----------------+
| Chrome 67     | Chrome 68       |
+---------------+-----------------+
| bottom: 97px; | bottom: 7898px; |
| right: 526px; | right: 510px;   |
+---------------+-----------------+
Sign up to request clarification or add additional context in comments.

Adding it to the <html> seems to fix it indeed !
It still keeps scrolling on firefox :/
@Viira - fixed but weird :D (see update)
I ain't lying bro T_T it's not working on Firefox. @SebastianBrosch
Not a bug. It just creates a new stacking context, also see here

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.