Skip to content

Instantly share code, notes, and snippets.

@fieldoffice
Last active August 29, 2015 14:10
Show Gist options
  • Save fieldoffice/786b18866d95cee98151 to your computer and use it in GitHub Desktop.
Save fieldoffice/786b18866d95cee98151 to your computer and use it in GitHub Desktop.
Sass Control Directives - if statement
//MIXIN
@mixin text-inset($colour, $opacity: 0.5) {
@if lightness($colour) < 50% {
//DARK TEXT - LIGHT SHADOW
text-shadow: 1px 1px 1px rgba(#fff, $opacity);
} @else {
//LIGHT TEXT - DARK SHADOW
text-shadow: -1px -1px 1px rgba(#000, $opacity);
}
// set the text colour
color: $colour;
}
//CSS
%example {
font-weight: bold;
text-transform: uppercase;
}
.example {
@extend %example;
@include text-inset(#fff, 0.3);
}
//MARKUP
<span class="example">Hello</span>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment