Answer the question
In order to leave comments, you need to log in
How to make automatic color matching?
I make a mixin, in which I pass the background color and, depending on it, through the condition and standard functions for working with color, sets the color of the text. If the background is dark, the color is white, and vice versa. I myself work in stylus, but I think each preprocessor will have more or less the same solutions. I myself used the stylus functions lightness, saturation, light, dark, but the desired result does not come out, it seems like everything is correctly selected for most colors, but it sometimes gives out white text to a light gray background (although black is more suitable there), then dark - red background black text.
There are probably some conditions for preprocessors for such a color selection? Please tell me how to do it right.
Answer the question
In order to leave comments, you need to log in
Less has a pretty handy option for finding a contrasting color using the contrast()
.
The simplest use case:
.contrast(@bg) {
color: contrast(@bg);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question