7 Uses for CSS Custom Properties

Publikováno: 27.12.2019

I find all seven of these quite clever and useful.

I particularly like using custom properties when you can sneak a variation into a place where you'd normally have to re-declare a whole big chunk of code.

.some-element {
  background-color: hsla(
    var(--h, 120),
    var(--s, 50),
    var(--l, 50),
    var(--a, 1)
  );
}

.some-element.darker {
  --l: 20;
}

Nice.

Direct Link to ArticlePermalinkRead article

The post 7 Uses for CSS Custom Properties appeared first on CSS-Tricks.

Celý článek

I find all seven of these quite clever and useful.

I particularly like using custom properties when you can sneak a variation into a place where you'd normally have to re-declare a whole big chunk of code.

.some-element {
  background-color: hsla(
    var(--h, 120),
    var(--s, 50),
    var(--l, 50),
    var(--a, 1)
  );
}

.some-element.darker {
  --l: 20;
}

Nice.

Direct Link to ArticlePermalink

The post 7 Uses for CSS Custom Properties appeared first on CSS-Tricks.

Nahoru
Tento web používá k poskytování služeb a analýze návštěvnosti soubory cookie. Používáním tohoto webu s tímto souhlasíte. Další informace