You can use the function lightness()for background-colorto determine the value coloras follows:
@function set-color($color) {
@if (lightness($color) > 40) {
@return #000;
}
@else {
@return #FFF;
}
}
Then use the above function as below:
div { background-color: black; // Or whatever else }
div p { color: set-color(black); }
LIVE DEMO .
source
share