Entry 08
overflow: clip over hidden
Use it whenever you want to cut off overflow and do not need scrolling.
Code
.hero { overflow-x: clip; }Why it works, the rules and the credits
Why it works
hiddenturns the element into a scroll container and sets the other axis toauto. That causes stray scrollbars and breaksposition: stickyinside it.clipcuts the overflow and does neither.
Rules
- Put it on the element that overflows, not on
htmlorbody. - Keep
hiddenorautofor elements a script scrolls.clipblocks that too. - Keep
hiddenorautoon an element withresize. Withclipthe browser draws no resize handle.
Support
- Chrome
- 90
- Firefox
- 81
- Safari
- 16
Credits
Borrowed from: Kevin Powell, 2 better alternatives to overflow: hidden, 2023-12-14