Tame the sticky elements that cover your content
A sticky header that stays 90 px tall while you scroll. A floating "subscribe to the newsletter" bar. A "back to top" button covering the last sentence of a paragraph. Elements glued to the screen can eat a third of the view. Here is how to tame them.
What glues them
Two CSS properties: position: sticky (the element sticks once you scroll to its place) and position: fixed (the element sits in place from the start). Both can be overridden.
Two approaches
Unstick — the element stays, but scrolls with the page. Good for headers that are useful, just do not need to be on top forever.
header, .site-header, .navbar,
[class*="sticky"], [class*="fixed"] {
position: static !important;
}
Hide — the element disappears entirely. Good for floating CTAs, "back to top" widgets, promo bars.
[class*="back-to-top"], [class*="scroll-top"],
[class*="sticky-cta"], [class*="floating-bar"] {
display: none !important;
}
How to find the culprit
Not sure which element is glued? Open the JustZix JS Console and type:
[...document.querySelectorAll('*')]
.filter(el => {
const p = getComputedStyle(el).position;
return p === 'fixed' || p === 'sticky';
})
.forEach(el => console.log(el));
The console lists every fixed and sticky element — hover each to see it on the page, then copy its class into the rule selector.
Pitfalls
- Unsticking a header can cost you cosmetically. Some layouts rely on the header being fixed; after
position: staticthe content below it may jump up. Usually acceptable, but check. - Not every sticky is bad. A sticky table of contents or a reading-progress bar can be useful — aim precisely, not wholesale.
- Partial-class selectors.
[class*="fixed"]also hits.fixed-width, which has nothing to do with positioning.position: staticon it breaks nothing, but it is worth knowing.
See also
- Examples — the chat-widget hiding snippet and others
- Hide cookie banners — related decluttering of intrusive elements
- Build your own reader mode — decluttering a page all the way
Install JustZix — and reclaim the screen taken by glued-on bars.
Rate this post
No ratings yet — be the first.