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

推荐订阅源

爱范儿
爱范儿
WordPress大学
WordPress大学
博客园 - 【当耐特】
The Cloudflare Blog
B
Blog
Last Week in AI
Last Week in AI
小众软件
小众软件
量子位
S
SegmentFault 最新的问题
V
Visual Studio Blog
博客园 - 叶小钗
美团技术团队
阮一峰的网络日志
阮一峰的网络日志
Hugging Face - Blog
Hugging Face - Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
宝玉的分享
宝玉的分享
A
About on SuperTechFans
雷峰网
雷峰网
J
Java Code Geeks
Microsoft Azure Blog
Microsoft Azure Blog
腾讯CDC
MongoDB | Blog
MongoDB | Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Martin Fowler
Martin Fowler

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