Comments (4)
Here was my initial attempt:
h2 { position: sticky; top: 0; background: white; }
h3 { position: sticky; top: 28px; background: white; }
h4 { position: sticky; top: 56px; background: white; }
h5 { position: sticky; top: 84px; background: white; }
h6 { position: sticky; top: 112px; background: white; }
The problem is that since we don't have sectioning containers, everything sticks to the top forever. If you add backgrounds (as I did above) this can be OK as, for each N, only the topmost hN shows. However this breaks down when you're looking inside a h4 and have recently scrolled past a h5; that recent h5 still shows up, leading to scenarios like this:
(Also, this really highlights how our section permalink markers are not lined up, boo.)
from whatwg.org.
There's also some z-index issues (easy to fix).
However the big problem here is that this breaks cross-links in the spec. They get hidden under the headers. Maybe there are margin or padding hacks you can do to fix that, but it's pretty bad. See https://stackoverflow.com/q/10732690/3191 and links from there for more.
from whatwg.org.
Some initial exploration makes me think that
position: sticky
was mostly designed to be used in conjunction with container elements
Yup, that's what I had in mind at the time.
from whatwg.org.
There's scroll-padding
/ scroll-margin
you could use, to make sure you scroll at least to a "safe" place. (40% of the viewport height or such maybe? If that intersects with sticky headers somehow, then the sticky headers are probably being non-helpful at that point)
from whatwg.org.
Related Issues (20)
- Too many files for deploy to list them all HOT 3
- convert-policy.py and Markdown HOT 4
- Add tests for convert-policy.py
- website-service-worker.js breaks after redirecting. HOT 3
- Update FAQ for AppCache removal HOT 1
- Review Drafts issue HOT 6
- List Twitter accounts on spec.whatwg.org
- deploy.sh (build resources) fails with unbound variable error
- Make deploy (and make remote) fail when EXTRA_FILES exist HOT 8
- convert_sg_db.py should alphabetize by standard name
- broken link to multipage HOT 1
- review.sh: make it easier to overwrite a copy
- Tweak color contrast of highlighting
- Consolidate colors
- SW fails to fetch spec CSS on first load of the day HOT 2
- Confusing UI for `<details>` in the Participant Agreement HOT 6
- Sort out hgroup usage HOT 3
- New checker for https://whatwg.org/validator/
- Store specification build outputs in git HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from whatwg.org.