-
Notifications
You must be signed in to change notification settings - Fork 23.1k
docs(css): add scroll-padding example for fixed header #42548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Preview URLs Flaws (11)URL:
(comment last updated: 2026-01-04 17:41:51) |
chrisdavidmills
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi there @lucifer13598, and thank you for your contribution to MDN.
I had a few comments for you; let me know what you think of them.
|
|
||
| {{Compat}} | ||
|
|
||
| ## Examples |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This entire section needs to be moved above the "Specifications" section.
|
|
||
| ### Preventing content from being hidden by a fixed header | ||
|
|
||
| A common use case for `scroll-padding` is when a page includes a fixed-position header. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| A common use case for `scroll-padding` is when a page includes a fixed-position header. | |
| A common use case for `scroll-padding` is to prevent scrolling content from being hidden by a fixed-position header. This example demonstrates how to use `scroll-padding` for this purpose. |
| ### Preventing content from being hidden by a fixed header | ||
|
|
||
| A common use case for `scroll-padding` is when a page includes a fixed-position header. | ||
| Without `scroll-padding`, content linked via fragment identifiers can be hidden beneath the header. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Without `scroll-padding`, content linked via fragment identifiers can be hidden beneath the header. |
| A common use case for `scroll-padding` is when a page includes a fixed-position header. | ||
| Without `scroll-padding`, content linked via fragment identifiers can be hidden beneath the header. | ||
|
|
||
| ```css |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As it stands, this doesn't really demonstrate the use case very clearly. Can you expand the example to show more complete code and a live example perhaps? It doesn't have to be as elaborate as this example, but this is the kind of pattern you should ideally follow: https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/scroll-target-group#basic_scroll-target-group_usage.
Description
Added a new example to the
scroll-paddingdocumentation demonstrating how it prevents content from being hidden behind a fixed-position header.Motivation
The existing documentation explained the concept but did not include a practical example. This change helps readers clearly understand a common real-world use case when using fragment links with fixed headers.
Additional details
No additional references required.
Related issues and pull requests
Fixes #42183