24 ms·
Interesting. Made me think to write a simple mixin for sass. @mixin fg-contrast($bg) { background: $bg; $textcolor: #ffffff; @if lightnes
by statenjason 16y ago
Interesting. Made me think to write a simple mixin for sass.
@mixin fg-contrast($bg) {
background: $bg;
$textcolor: #ffffff;
@if lightness($bg) > 50% {
$textcolor: #000000;
}
color: $textcolor;
}
Could also be done by using the red(), green(), and blue() functions, but lightness was simpler.
- chriseppstein 16y agoBingo! Such logic is supposed to live in the stylesheets with the design.