Topic: A linked tab panel scrolls underneath the fixed page header
Julia Hayes
free
asked 6 days ago
Our long account page has a fixed toolbar above its pills navigation. Opening a link to a panel selects the right section, but the browser positions its heading behind the toolbar.
The toolbar is about five rem tall on desktop. Is there a CSS approach for the anchor offset so we do not have to add a large permanent spacer above every panel?
Igor Przybysz
staff
answered 6 days ago
Apply scroll-margin-top to the element that receives the fragment or scrollIntoView target. It supplies a scroll offset without adding permanent spacing to the normal document layout. The tab still needs to be activated before scrolling to a panel that starts hidden.
Use the actual fixed-header height for each layout and include a small visual gap if needed. If your header wraps on smaller screens, adjust the value at the same breakpoint or maintain it through your existing header-height CSS variable.
.settings-panel-anchor {
scroll-margin-top: calc(var(--settings-header-height, 5rem) + 1rem);
}
https://mdbootstrap.com/docs/standard/navigation/pills/
FREE CONSULTATION
Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.
Answered
- ForumUser: Free
- Premium support: No
- Technology: MDB Standard
- MDB Version: MDB5 9.3.0
- Device: Desktop
- Browser: Safari
- OS: macOS
- Provided sample code: No
- Provided link: No