Sass: Use black or white foreground color depending on the lightness of the background

Posted . Visible to the public.

This article shows how to create a Sass mixin for a colored button. The button's foreground color is dynamically chosen between either black or white, depending on the given background color.

It's a nice intro into @if and @else conditionals in Sass.

Profile picture of Henning Koch
Henning Koch
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2012-03-07 21:24)