Last active
December 19, 2015 08:19
-
-
Save bencooling/5925206 to your computer and use it in GitHub Desktop.
Sass: mixins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin box-emboss($opacity, $opacity2){ | |
box-shadow:white($opacity) 0 1px 0, inset black($opacity2) 0 1px 0; | |
} | |
/* | |
.box { @include box-emboss(0.8, 0.05); } | |
*/ | |
@mixin letterpress($opacity){ | |
text-shadow:white($opacity) 0 1px 0; | |
} | |
@mixin box-shadow($top, $left, $blur, $color, $inset:"") { | |
-webkit-box-shadow:$top $left $blur $color #{$inset}; | |
-moz-box-shadow:$top $left $blur $color #{$inset}; | |
box-shadow:$top $left $blur $color #{$inset}; | |
} | |
/* | |
|-------------------------------------------------------------------------- | |
| Functions | |
|-------------------------------------------------------------------------- | |
*/ | |
@function rem($pxval, $base:16) { | |
@return ($pxval / $base) * 1rem; | |
} | |
/* | |
|-------------------------------------------------------------------------- | |
| Mixins | |
|-------------------------------------------------------------------------- | |
*/ | |
// #selector { @include rgba-background-fallback(#333, 0.5); } | |
@mixin rgba-background-fallback($color, $opacity: 1.0) { | |
background-color: $color; /* The Fallback */ | |
background-color: rgba($color, $opacity); | |
} | |
@mixin rgba-color-fallback($color, $opacity: 1.0) { | |
color: $color; /* The Fallback */ | |
color: rgba($color, $opacity); | |
} | |
@mixin rem-font-size($pxval, $base:16) { | |
font-size: $pxval * 1px; | |
font-size: rem($pxval, $base); | |
} | |
@mixin opacity($opacity){ | |
opacity: $opacity; | |
$opacity-ie: $opacity * 100; | |
filter: alpha(opacity=$opacity-ie); // ie8 | |
} | |
// Taken from Compass framework | |
// Usage: http://compass-style.org/reference/compass/layout/sticky_footer/ | |
@mixin sticky-footer($footer-height, $root-selector: unquote("#root"), $root-footer-selector: unquote("#root_footer"), $footer-selector: unquote("#footer")) { | |
html, body { | |
height: 100%; } | |
#{$root-selector} { | |
clear: both; | |
min-height: 100%; | |
height: auto !important; | |
height: 100%; | |
margin-bottom: -$footer-height; | |
#{$root-footer-selector} { | |
height: $footer-height; } } | |
#{$footer-selector} { | |
clear: both; | |
position: relative; | |
height: $footer-height; } } | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@mixin modifier($modifier) { | |
@if (str-index(#{$modifier}, 'shadow')){ | |
color: red; | |
} | |
} | |
.test--shadow { | |
color: blue; | |
@include modifier(&); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment