[!NOTE] postcss-cssnext a été déprécié au profit de postcss-preset-env. Cet aide-mémoire sert de référence pour les projets historiques.
Propriétés personnalisées CSS (Variables)
:root {
--primary-color: #3b82f6;
--spacing-base: 1rem;
}
.button {
background: var(--primary-color);
padding: var(--spacing-base);
}
Sélecteurs personnalisés & Imbrication
Sélecteurs personnalisés
@custom-selector :--heading h1, h2, h3, h4, h5, h6;
:--heading {
margin-top: 0;
font-weight: 700;
}
Imbrication CSS native
.card {
padding: 1rem;
& .title {
font-size: 1.25rem;
}
&:hover {
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
}
Requêtes médias personnalisées
@custom-media --small-viewport (max-width: 30em);
@custom-media --large-viewport (min-width: 60em);
@media (--small-viewport) {
body {
font-size: 14px;
}
}
Fonctions de couleur fonctionnelles
a {
/* Ajustement relatif d'opacité */
color: color(var(--primary-color) alpha(-20%));
color: color(red tint(20%)); /* Éclaircir */
color: color(blue shade(30%)); /* Assombrir */
/* Gris par valeur RGB */
background: gray(50);
/* Gris par pourcentage de luminosité */
background: gray(80%);
}