Interview practice question
The page scrolls behind an open modal
Frontend Engineering · HTML and CSS · Intermediate
When a modal is open, the page behind it still scrolls. How do you fix this properly?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Lock scroll on body/html (overflow hidden).
- Prevent layout shift from scrollbar (scrollbar-gutter).
- overscroll-behavior: contain in modal.
- Restore on close.
- Native dialog element.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.