Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,26 @@ scroll-padding: unset;

{{Compat}}

## Examples
Comment thread
estelle marked this conversation as resolved.

### 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.
Comment thread
estelle marked this conversation as resolved.
Outdated
Without `scroll-padding`, content linked via fragment identifiers can be hidden beneath the header.
Comment thread
estelle marked this conversation as resolved.
Outdated

```css
Copy link
Copy Markdown
Contributor

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.

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)
Expand Down