惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

G
GRAHAM CLULEY
C
CXSECURITY Database RSS Feed - CXSecurity.com
P
Privacy International News Feed
W
WeLiveSecurity
C
Cybersecurity and Infrastructure Security Agency CISA
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
P
Proofpoint News Feed
WordPress大学
WordPress大学
Blog — PlanetScale
Blog — PlanetScale
Project Zero
Project Zero
H
Help Net Security
B
Blog RSS Feed
T
Threatpost
Microsoft Azure Blog
Microsoft Azure Blog
C
Check Point Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
阮一峰的网络日志
阮一峰的网络日志
S
SegmentFault 最新的问题
博客园 - 【当耐特】
月光博客
月光博客
Google Online Security Blog
Google Online Security Blog
NISL@THU
NISL@THU
The GitHub Blog
The GitHub Blog
P
Privacy & Cybersecurity Law Blog
N
News | PayPal Newsroom
T
Tenable Blog
Simon Willison's Weblog
Simon Willison's Weblog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
G
Google Developers Blog
小众软件
小众软件
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
GbyAI
GbyAI
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Jina AI
Jina AI
J
Java Code Geeks
Recent Announcements
Recent Announcements
TaoSecurity Blog
TaoSecurity Blog
MongoDB | Blog
MongoDB | Blog
T
Troy Hunt's Blog
V
Visual Studio Blog
博客园_首页
L
LangChain Blog
SecWiki News
SecWiki News
O
OpenAI News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Hacker News: Ask HN
Hacker News: Ask HN
S
Schneier on Security
A
Arctic Wolf
U
Unit 42

Starred Articles

Improvements to Web for AI Should Benefit All Users New to the web platform in April  |  Blog  |  web.dev Delivering a dynamic hexagonal world map in just 10kb | Calibre My house alerts me when my cat climbs into the ceiling Eames Pavilion System Squarespace & Web Standards: How We Helped Bring HTML Video & Audio Lazy Loading to Today’s Browsers | Scott Jehl, Web Designer/Developer The Web is a Guitar Amp Now (Literally) Making keyboard navigation effortless I used Claude Code and GSD to build the accessibility tool I’ve always wanted - blakewatson.com Sizing chaos Scroll indicators on tables with background colours using animation-timeline Webspace Invaders Fresh Hot CSS: Trig Functions The Year Of The Linux Desktop (for fitness games) Almost Plain Text, Nicely Done – Email is good. Uncrate's 100-ish favorite things on Amazon VS Code – highlight just the active indent guide How musicals use motifs to tell stories Good Tidings! Review: MoErgo Go60, a split ergonomic and fully programmable keyboard The line and the stream. — Ethan Marcotte Testing HTML Light DOM Web Components: Easier Than Expected! Enhancing Web Components Safely with Self-Destructing CSS | Scott Jehl, Web Designer/Developer Steam Machine Caira AI Mirrorless Camera A Treatise on AI Chatbots Undermining the Enlightenment Talking CSS, Web Components, App Design and (gulp) AI on ShopTalk Show Microsoft™ Ergonomic Keyboard (now sold by Incase) A new, new logo for the W3C Chris Coyier closedBy=any · October 16, 2025 Paxos accidentally mints more than twice the global GDP in PayPal stablecoins The CSS Podcast is back! And I’m a co-host now. Who needs a flying car when you have display: grid Junior Dev Tip: "Scroll Up" WWW Ep212 With Dave Rupert · October 2, 2025 DHH Is Way Worse Than I Thought | jakelazaroff.com A custom --light-dark() function in CSS that works with any type of value (not just colors!) in just 3 LOC Make accessible carousels  |  Blog  |  Chrome for Developers 37 pm · Paul Robert Lloyd Against the protection of stocking frames. — Ethan Marcotte “Why would anybody start a website?” Necropolis Should Men Be the Head of Every Household? The History of Themeable User Interfaces Speeding up my Learning Log process Eight years of Jessie How our dog increased my appreciation for accessibility In the Future All Food Will Be Cooked in a Microwave, and if You Can’t Deal With That Then You Need to Get Out of the Kitchen Somewhere Between Lost and Found Impact of AI on Tech Content Creators Progressive Enhancement and Web Components Sizzle Rizzle · July 4, 2025 The Cascade
Solved by CSS Scroll State Queries: hide a header when scrolling down, show it again when scrolling up.
Published by Bramus! · 2025-10-23 · via Starred Articles

Recording of the demo, recorded in Chrome Canary.

There’s a new type of CSS scroll-state query coming: scrolled

~

Unlike the scrollable scroll-state queries, scrolled remembers the last direction you scrolled into, which you can use to build “hidey bars”: when scrolling down (or having scrolled down), the hidey bar hides itself. When then scrolling back up, the hidey bar reveals itself.

Here’s the code that is needed to hide a fixed header when scrolling down:

html {
  container-type: scroll-state;
}

header {
  transition: translate 0.25s;
  translate: 0 0;

  /* Slide header up when last having scrolled towards the bottom */
  @container scroll-state(scrolled: bottom) {
    translate: 0 -100%;
  }
}

Good suggestion by meduz on Mastodon, in case the header contains some interactive content that you can focus:

Use header:not(:focus-within) to avoid hiding the bar if there’s focus in it.

~

Below is a live demo using the code above. You can try it out yourself in Chrome Canary with the experimental Web Platform Features Flag enabled. If you browser does not support scrolled scroll-state queries, the header will remain fixed in place – a nice progressive enhancement if you’d ask me 🙂

See the Pen
Hidey Bar Demo (Hide on Scroll Down, Show on Scroll Up // Scroll State Queries)
by Bramus (@bramus)
on CodePen.

The feature is expected to ship to Chrome Stable in Chrome 144.

~

~

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)