Stop Sticky Headers Covering Jump-Link Targets
Leaves space above headings and sections when visitors follow a #link, so the target is not hidden under a sticky header or the admin bar.
Opens WPIDE on
Code
:root {
--wpide-header-offset: 90px;
}
html {
scroll-padding-top: var(--wpide-header-offset);
}
.admin-bar {
scroll-padding-top: calc(var(--wpide-header-offset) + var(--wp-admin--admin-bar--height, 32px));
}
Notes
Set --wpide-header-offset to the height of your sticky header.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.