Show Notes
In this Hasty Treat, Scott and Wes talk about CSS container queries, what they are and how to use them.
Sanity - SponsorSanity.ioΒ is a real-time headless CMS with a fully customizable Content Studio built in React. Get a Sanity powered site up and running in minutes atΒ sanity.io/create. Get an awesome supercharged free developer plan onΒ sanity.io/syntax.
LogRocket - SponsorLogRocket lets you replay what users do on your site, helping you reproduce bugs and fix issues faster. Itβs an exception tracker, a session re-player and a performance monitor. Get 14 days free atΒ logrocket.com/syntax.
Show Notes07:22 - Why?
- Container queries are media queries for components (e.g. they are based on the elementβs size, not the browser).
- This is in line with how we write components.
- It will change the way we write CSS.
08:49 - The Syntax
- Containers need to be defined as containers via containment context
New contain value:
.inline-container { contain: inline-size; }This is the same as the logical properties. Assuming you read LTR, or RTL:
- size - width and height
- inline-size = width
- block-size = height
18:49 - How to try them today
- Download and/or update Chrome Canary
- Go to chrome://flags
- Search and enable βCSS Container Queriesβ
- Restart the browser
19:27 - Demos
- Need Chrome Canary + Flag
- https://codepen.io/collection/XQrgJo
- https://codepen.io/una/pen/LYbvKpK?editors=1100
- Miriam Suzanne
- Susy
- Miriamβs CSS Sandbox
- https://css.oddbird.net/rwd/query/explainer/
- Canary
- @addyosmani
- The CSS Podcast
- @jon_neal
- Scottβs Instagram
- LevelUpTutorials Instagram
- Wesβ Instagram
- Wesβ Twitter
- Wesβ Facebook
- Scottβs Twitter
- Make sure to includeΒ @SyntaxFMΒ in your tweets
