Last active
October 14, 2015 01:47
-
-
Save mauryaratan/4288446 to your computer and use it in GitHub Desktop.
Useful SCSS 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 md($case){ | |
.#{$case} &{ | |
@content; | |
} | |
} | |
@mixin the-bg($trans: 1){ | |
background: url(assets/img/pixel-#{$trans}.png) repeat; | |
background: rgba(black, ($trans/10)); | |
} | |
//Rem generator | |
$baseline-px: 15px; | |
@mixin rem($property, $px-values) { | |
// Convert the baseline into rems | |
$baseline-rem: $baseline-px / 1rem; | |
// Print the first line in pixel values | |
#{$property}: $px-values; | |
// If there is only one (numeric) value, return the property/value line for it. | |
@if type-of($px-values) == "number" { | |
#{$property}: $px-values / $baseline-rem; } | |
@else { | |
// Create an empty list that we can dump values into | |
$rem-values: unquote(""); | |
@each $value in $px-values { | |
// If the value is zero, return 0 | |
@if $value == 0 { | |
$rem-values: append($rem-values, $value); } | |
@else { | |
$rem-values: append($rem-values, $value / $baseline-rem); } } | |
// Return the property and its list of converted values | |
#{$property}: $rem-values; } } | |
@mixin icon-font($c){ | |
content: '#{$c}'; | |
font-family: FontAwesome; | |
font-weight: normal; | |
font-style: normal; | |
text-decoration: inherit; | |
-webkit-font-smoothing: antialiased; | |
*margin-right: .3em; | |
} | |
.clearfix, %clearfix { | |
zoom: 1; | |
&:before, | |
&:after { | |
display: table; | |
content: ""; | |
} | |
&:after { | |
clear: both; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment