[!NOTE] postcss-cssnext wurde zugunsten von postcss-preset-env als veraltet eingestuft. Dieser Spickzettel dient als Referenz für Legacy-Projekte mit cssnext-Syntax.
CSS Custom Properties (Variablen)
:root {
--primary-color: #3b82f6;
--spacing-base: 1rem;
}
.button {
background: var(--primary-color);
padding: var(--spacing-base);
}
Benutzerdefinierte Selektoren & Nesting
Benutzerdefinierte Selektoren
@custom-selector :--heading h1, h2, h3, h4, h5, h6;
:--heading {
margin-top: 0;
font-weight: 700;
}
Natives CSS Nesting
.card {
padding: 1rem;
& .title {
font-size: 1.25rem;
}
&:hover {
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
}
Benutzerdefinierte Media Queries
@custom-media --small-viewport (max-width: 30em);
@custom-media --large-viewport (min-width: 60em);
@media (--small-viewport) {
body {
font-size: 14px;
}
}
Funktionale Farbfunktionen
a {
/* Relative Deckkraft-Anpassung */
color: color(var(--primary-color) alpha(-20%));
color: color(red tint(20%)); /* Aufhellen */
color: color(blue shade(30%)); /* Abdunkeln */
/* Graustufen über RGB-Wert */
background: gray(50);
/* Graustufen über Helligkeitsprozentsatz */
background: gray(80%);
}