-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -123,6 +123,26 @@ scroll-padding: unset; | |||||
|
|
||||||
| {{Compat}} | ||||||
|
|
||||||
| ## Examples | ||||||
|
|
||||||
| ### 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. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| Without `scroll-padding`, content linked via fragment identifiers can be hidden beneath the header. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| ```css | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||||||
| header { | ||||||
| position: fixed; | ||||||
| top: 0; | ||||||
| height: 60px; | ||||||
| width: 100%; | ||||||
| } | ||||||
|
|
||||||
| html { | ||||||
| scroll-padding-top: 60px; | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| ## See also | ||||||
|
|
||||||
| - [CSS scroll snap](/en-US/docs/Web/CSS/Guides/Scroll_snap) | ||||||
|
|
||||||
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.