HTML & CSS · Middle · Question 29 of 75

position: sticky isn't working even though top: 0 is set. What's the most likely cause?

Explanation

A sticky element sticks to its nearest scrolling ancestor. If an ancestor's overflow isn't visible, sticky is measured against it, and that ancestor may not scroll at all - visually nothing happens. Another cause: the parent is no taller than the element, so there's nowhere to stick. To clip without creating a scroll container, use overflow: clip.

Further reading

Problem with a question

HTML & CSS · Middle · question 29

Test yourself

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

Take this quiz