Skip to content

Instantly share code, notes, and snippets.

@fjahn
Created May 5, 2021 09:53
Show Gist options
  • Save fjahn/c07eb6939c927e2ce432586310b5e660 to your computer and use it in GitHub Desktop.
Save fjahn/c07eb6939c927e2ce432586310b5e660 to your computer and use it in GitHub Desktop.
Readable Text Mixin
/**
Ensures that text is readable on any background.
Stolen from https://stackoverflow.com/questions/23968961/css-how-can-i-make-a-font-readable-over-any-color#43135326
*/
@mixin readable-shadow($size, $color: white) {
text-shadow:
#{0.01 * $size}em 0 $color,
0 #{0.01 * $size}em $color,
#{-0.01 * $size}em 0 $color,
0 #{-0.01 * $size}em $color,
#{-0.01 * $size}em #{-0.01 * $size}em $color,
#{-0.01 * $size}em #{0.01 * $size}em $color,
#{0.01 * $size}em #{-0.01 * $size}em $color,
#{0.01 * $size}em #{0.01 * $size}em $color;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment