MultiDev
MultiDev

Reputation: 10659

CSS: How to change only one value using hsl color

Is there any way to adjust only specific values using hsl? For example, if I only want to change the saturation or lightness and keep the hue the same?

.red {
    background-color: #ff0000; /* or, hsl(0,100%,50%); */
}
.red-dark { // Adjust saturation +10% and lightness -15%
    background-color: hsl(, +10%, -15%);
}

Upvotes: 5

Views: 1955

Answers (1)

Serg Chernata
Serg Chernata

Reputation: 12400

You'll need to use javascript or a css preprocessor like sass, as mentioned by Fran.

CSS is declarative and has no reference to previous condition with a few small exceptions. For the most part, it only executes what it is given.

Upvotes: 1

Related Questions