(AKA things you may have missed
in the last 5 years)
Alex Riviere
Senior Web Developer at Nexcor Food Safety Technology
https://alex.party
display:flex;
display:grid;
var(--custom-property);
@layer
@container
@scope
:has()
body {
color: #000000;
background-color: #ffffff;
}
.invert {
color: #ffffff;
background-color: #000000;
}
// _vars.scss
$color-ink: #000000;
$color-paper: #ffffff;
// _style.scss
body{
color: $color-ink;
background-color: $color-paper;
}
.invert{
color: $color-paper;
background-color: $color-ink;
}
:root{
--color-ink: #000000;
--color-paper: #ffffff;
}
body{
color: var(--color-ink);
background-color: var(--color-paper);
}
.invert{
color: var(--color-paper);
background-color: var(--color-ink);
}
Bonus round?
(Bonus Round)
@property --my-color{
syntax: "<color>";
inherit: true;
initial-value: black;
}
p{
color: var(--my-color);
}
(Credit: Miriam Suzanne)
(Credit: Jen Simmons)
min() Example
max() Example
clamp() Example
A Common Problem
.input-wrapper:has(input:invalid)
<div class="input-wrapper">
<input type="email" value="alex" />
</div>
:has()
This:has(a.solution)
.text-red{
color:red;
}
.my-class{
color:blue;
}
.text-red{
color:red !important;
}
.my-class{
color:blue;
}
.my-class{
color:blue;
}
.text-red{
color:red;
}
.my-wrapper .my-class{
color:blue;
}
.text-red{
color:red;
}
@layer style, utility;
@layer style {
.my-wrapper .my-class{
color:blue;
}
}
@layer utility{
.text-red{
color:red;
}
}
@layer style, utility;
@layer utility{
.text-red{
color:red;
}
}
@layer style {
.my-wrapper .my-class{
color:blue;
}
}
@layer framework, style, utility;
@import url('framework.css') layer(framework);
@layer utility{
.text-red{
color:red;
}
}
@layer style {
.my-wrapper .my-class{
color:blue;
}
}
.blue-box{
display:grid;
grid-template-columns: 1fr;
}
@media screen and (min-width: 450px) and (max-width: 1023px){
.blue-box{
grid-template-columns: 1fr 1fr;
}
}
@media screen and (min-width: 1024px) and (max-width: 1439px){
.blue-box{
grid-template-columns: 1fr;
}
}
@media screen and (min-width: 1440px){
.blue-box{
grid-template-columns: 1fr 1fr;
}
}
.blue-box-wrapper{
container-type: inline-size;
container-name: blue-box;
}
.blue-box{
display:grid;
grid-template-columns: 1fr;
}
@container blue-box (min-width: 450px) {
.blue-box {
grid-template-columns: 1fr 1fr;
}
}
<style>
p{
color:red;
}
</style>
<p>This is red text!</p>
<style>
p{ color:red; }
</style>
<p>This is red text!</p>
<div>
<style>
@scope{
p{ color: blue; }
}
</style>
<p>
This text is blue!
</p>
</div>
*Available in Safari Technical Preview
sin()
cos()
tan()
asin()
acos()
atan()
atan2()
/* before.... */
.wrapper .title{
/* styles */
}
.wrapper .content{
/* styles */
}
.wrapper .actions{
/* styles */
}
/* after.... */
.wrapper {
.title{
/* styles */
}
.content{
/* styles */
}
.actions{
/* styles */
}
}
Jon Neal - For making an app that says the date when features were added to the browser
Alex Riviere
CodePens: