HTML & CSS · Senior · Question 12 of 75

What happens to a position: fixed element if an ancestor has transform: translateZ(0)?

Explanation

An ancestor with transform, filter, perspective, contain: paint or will-change: transform becomes the containing block for fixed descendants. A modal inside an animated container suddenly "sticks" to the container instead of the window. That's why modals and toasts are rendered through a portal at body level.

Further reading

Problem with a question

HTML & CSS · Senior · question 12

Test yourself

Take the HTML & CSS · Senior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz