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

推荐订阅源

Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
阮一峰的网络日志
阮一峰的网络日志
博客园_首页
Last Week in AI
Last Week in AI
月光博客
月光博客
D
DataBreaches.Net
WordPress大学
WordPress大学
雷峰网
雷峰网
酷 壳 – CoolShell
酷 壳 – CoolShell
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 叶小钗
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
U
Unit 42
Recent Announcements
Recent Announcements
宝玉的分享
宝玉的分享
MyScale Blog
MyScale Blog
C
Check Point Blog
F
Fortinet All Blogs
B
Blog
小众软件
小众软件
Vercel News
Vercel News
罗磊的独立博客
有赞技术团队
有赞技术团队

Miriam Eric Suzanne

Butter bells, fresh from the kiln Butter bells, fresh from the kiln Butter bells, fresh from the kiln I had to look it up I Laser-cut pottery throwing gauge Tech continues to be political Aggregating my distributed self A web component for CodePen embeds? We don Eleventy buckets & cascade layers A slash-why proposal User styles on the web Custom element, two ways New year, same (terrible) Mia CSS @scope Reclaiming my time Cascade Layers Javascript automation on Mac Personal Histories Ancient Web Browsers Critical CSS? Not So Fast! CSS tie-dye gradient backgrounds Personal website redesign Request for Comments: Sass Color Spaces A long-term plan for logical properties? I never let things be small A whole cascade of layers This content won No demo [website] reno
Container queries in browsers!
2022-09-14 · via Miriam Eric Suzanne

After nearly 15 years as a highly-requested feature in CSS – and 15 years being told it was impossible – (size) Container Queries and units have shipped in both Chrome/Edge 105, and Safari 16! Firefox is not far behind.

If you want to start using these features (I recommend it!) just make sure you’re using the right syntax! Some things have changed between the first prototype and the final version that’s shipping in browsers. But don’t worry – it’s stable now, and won’t be changing again!

Both Chrome 105 and Safari 16 come with an impressive list of new features in addition to container queries. The main highlights are the :has() selector (in both) and subgrid (in Safari). But I recommend digging through the release notes linked above.

(For more about container size queries and units, see my list of Container Query Resources.)

Style Queries Prototype

Meanwhile, Chrome Canary & Edge Canary have both shipped a prototype of style queries. Rather than measuring the dimensions of an element, style queries measure the computed value of a given property on that element.

To test the feature:

  • Download either Canary browser.
  • Navigate to about://flags/#enable-experimental-web-platform-features.
  • Set it to Enabled.
  • Restart the browser.

For now style queries are limited to strict equality (we can’t query number ranges, or partial values) – and the prototype is limited to custom properties. Even with those limitations, it’s a pretty powerful feature. Here’s my first experiment, establishing two ‘button themes’ – mia and mia-plus – toggled by a single custom property:

I’m excited to experiment with this more. It should enable most of the use-cases in Lea Verou’s request for Higher Level Custom Properties, and I’m excited to see what else people come up with. If you make any demos, please send them my way!

Browser Support for Size Queries & Units

Support data from CanIUse.com on the css-container-queries feature Support data from CanIUse.com on the css-container-query-units feature

© Miriam Eric Suzanne,
protect trans kids