DEV Community

Takaaki
Takaaki

Posted on

When `position: fixed;` is not working.

Hello, This is my first posting :)

If a parent elements has transform properties, position: fixed; of children elements does not be working.

That case, The children elements behave like position: absolute;.

Solution to the problem

If a parent elements uses transform animation, Replace without transform animation. or Remove transform properties or Set transform: none;.

Top comments (11)

Collapse
 
mwauramuchiri profile image
MwauraMuchiri

Also if the parent element has a " will-change: transform; " attribute, the fixed child element will be relative to the parent

Collapse
 
mauronava_dev profile image
Mauro Nava • Edited

Also, if the parent element is using the perspective attribute, the fixed postion will not work in the child.

Collapse
 
arminops profile image
Armin Tor

Big experience to me :) Thanks.

Collapse
 
adiusz profile image
Adam Leszczyński

omg dude, thanks a lot, I would never have guessed : D

Collapse
 
kevinas28 profile image
Kevin AS

THANKS A LOT

Collapse
 
afif profile image
Temani Afif

related for more details: stackoverflow.com/a/52937920/8620333

Collapse
 
kamcio profile image
kamcio

Also, if the parent element has a contain attr with a value set to content, layout, paint or strict than it will not work.

Collapse
 
pingzoo profile image
pingzoo

Thanks... That was the solution :D

Collapse
 
frabatx profile image
Frabatx

Also, if the parent is using backdrop-filter: blur().
I spent 3 days on in

Collapse
 
capanov profile image
capanovitch23

Absolute lifesaver bro thank you

Collapse
 
doctorderek profile image
Dr. Derek Austin 🥳

Solid, thanks Takaaki