HTML & CSS
/Intermediate
Fixed
Definition
Removes the element from the normal document flow and positions it relative to the viewport (the browser window). It stays in the exact same place even when the page is scrolled.
Explain Like I'm New
Imagine putting a sticker directly onto your computer monitor. Even if you scroll the website up and down, the sticker never moves because it is stuck to the glass of the screen, not the webpage.
Real World Example
A persistent navigation bar at the top of a website that follows you as you scroll down. A 'Chat with Support' bubble permanently stuck in the bottom-right corner.
Common Use Cases
- •Sticky headers/footers
- •Floating Action Buttons (FABs)
Interactive Example
Interview Questions
basic
- Does a `fixed` element care about parent containers?
intermediate
- Why does content sometimes hide underneath a fixed header?