In this Hasty Treat, Scott and Wes talk about CSS nesting — what it is, when to use it, and why.
Prismic is a Headless CMS that makes it easy to build website pages as a set of components. Break pages into sections of components using React, Vue, or whatever you like. Make corresponding Slices in Prismic. Start building pages dynamically in minutes. Get started at prismic.io/syntax.
If you want to know what’s happening with your code, track errors and monitor performance with Sentry. Sentry’s Application Monitoring platform helps developers see performance issues, fix errors faster, and optimize their code health. Cut your time on error resolution from hours to minutes. It works with any language and integrates with dozens of other services. Syntax listeners new to Sentry can get two months for free by visiting Sentry.io and using the coupon code TASTYTREAT during sign up.
04:22 - What is it?
06:02 - Why nest?
08:13 - When to use nesting
10:06 - Nesting prefixes
.tweet { & > p { } &.media-included { color: green; } & + .tweet { } // sibling & p { } // descentang }
article{ color: blue; & { color: red; } }
and must be the first child of a compound selector
12:44 - @nest rule / media queries
.foo { display: grid; @media(orientation: landscape) { & { grid-auto-flow: column; } } }
.foo { display: grid; @media (orientation: landscape) { & { grid-auto-flow: column; } @media (min-inline-size > 1024px) { & { max-inline-size: 1024px; } } } } /* equivalent to .foo { display: grid; } @media (orientation: landscape) { .foo { grid-auto-flow: column; } } @media (orientation: landscape) and (min-inline-size > 1024px) { .foo { max-inline-size: 1024px; } } */
16:30 - How to use nesting today
📆 2021-04-05 15:00 / ⌛ 00:22:23
📆 2021-03-31 15:00 / ⌛ 01:00:04
📆 2021-03-29 15:00 / ⌛ 00:20:06
📆 2021-03-24 14:00 / ⌛ 01:00:49