-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(#1932): implement smooth scrolling for anchor navigation across site #1965
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: gh-pages
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 | ||||
---|---|---|---|---|---|---|
@@ -1,6 +1,20 @@ | ||||||
* { | ||||||
box-sizing: border-box; | ||||||
-webkit-tap-highlight-color: transparent; | ||||||
scroll-behavior: smooth; | ||||||
} | ||||||
|
||||||
/* handle header offset with scroll-margin */ | ||||||
h1, h2, h3, h4, h5, h6, | ||||||
[id] { | ||||||
scroll-margin-top: 120px; | ||||||
} | ||||||
Comment on lines
+8
to
+11
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. I'm not sure if this is actually doing anything, and if it's supposed to have the same effect as in the MDN example https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-margin-top, then I'm -1 on this, I don't think we should do it. 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.
We can clearly see that margin spaces added to the header on scroll from the top of the viewport. In our context, why it is important?
This happens if top navigation is positioned sticky at the top. See image, It is not required right now, without scroll top margin, header scroll into viewport at top 0px. But I think adding some small margin 60px to the top looks good for me. Also our header is 57px height. Maybe I will go with sticky top navigation bar in #1943. |
||||||
|
||||||
/* Respect user motion preferences for access */ | ||||||
@media (prefers-reduced-motion: reduce) { | ||||||
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. It is Good practice to consider accessibility |
||||||
html { | ||||||
scroll-behavior: auto; | ||||||
} | ||||||
} | ||||||
|
||||||
body { | ||||||
|
@@ -264,11 +278,6 @@ a { | |||||
padding-top: 40px; | ||||||
} | ||||||
|
||||||
#api-doc *:target, #page-doc *:target { | ||||||
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. I support removing this |
||||||
margin-top: -120px; | ||||||
padding-top: 120px; | ||||||
z-index: -1; | ||||||
} | ||||||
|
||||||
/* logo */ | ||||||
.logo-container a { | ||||||
|
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.
see comment https://github.com/expressjs/expressjs.com/pull/1965/files#r2206464995