Created
May 3, 2012 03:06
-
-
Save jgarber623/2582733 to your computer and use it in GitHub Desktop.
My collection of SASS/Compass mixins
This file contains hidden or 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
// display: block | |
@mixin block( $width: 0, $height: 0 ) { | |
display: block; | |
height: $height; | |
width: $width; | |
} | |
// CSS3: backface-visibility | |
@mixin backface-visibility( $style: visible ) { | |
@each $prefix in -moz, -ms, -o, -webkit { | |
#{$prefix}-backface-visibility: $style; | |
} | |
backface-visibility: $style; | |
} | |
// CSS3: perspective | |
@mixin perspective( $style: none ) { | |
@each $prefix in -moz, -ms, -o, -webkit { | |
#{$prefix}-perspective: $style; | |
} | |
perspective: $style; | |
} | |
// CSS3: transform-style | |
@mixin transform-style( $style: flat ) { | |
@each $prefix in -moz, -ms, -o, -webkit { | |
#{$prefix}-transform-style: $style; | |
} | |
transform-style: $style; | |
} | |
// @font-face | |
@mixin font-face( $name, $filename, $svg_id, $style:normal, $weight:normal ) { | |
@font-face { | |
font-family: "#{$name}"; | |
font-style: $style; | |
font-weight: $weight; | |
src: font-url( "#{$filename}.eot" ); | |
src: font-url( "#{$filename}.eot?#iefix" ) format( "embedded-opentype" ), | |
font-url( "#{$filename}.woff" ) format( "woff" ), | |
font-url( "#{$filename}.ttf" ) format( "truetype" ), | |
font-url( "#{$filename}.svg##{$svg_id}" ) format( "svg" ); | |
} | |
} | |
// Generated content | |
@mixin generated-content( $width: 0, $height: 0 ) { | |
content: ""; | |
display: block; | |
height: $height; | |
position: absolute; | |
width: $width; | |
} | |
// Gradients for IE | |
@mixin filter-gradient( $start-color, $end-color, $orientation: vertical ) { | |
$gradient-type: if ( $orientation == vertical, 0, 1 ); | |
-ms-filter: "progid:DXImageTransform.Microsoft.gradient( gradientType=#{$gradient-type}, startColorstr='#{ie-hex-str( $start-color )}', endColorstr='#{ie-hex-str( $end-color )}' )"; | |
filter: progid:DXImageTransform.Microsoft.gradient( gradientType=#{$gradient-type}, startColorstr="#{ie-hex-str( $start-color )}", endColorstr="#{ie-hex-str( $end-color )}" ); | |
} | |
// Inline icons | |
@mixin inline-icon( $width: 0, $height: 0, $margin: 0 ) { | |
display: inline-block; | |
height: $height; | |
margin: $margin; | |
vertical-align: middle; | |
width: $width; | |
} | |
// Opacity | |
@mixin opacity( $opacity ) { | |
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha( Opacity=#{round( $opacity * 100 )} )"; | |
filter: alpha( opacity=#{round( $opacity * 100 )} ); | |
opacity: $opacity; | |
} | |
// Pinstripes | |
@mixin pinstripe( $background-image, $opacity, $pseudo-element:before ) { | |
> * { | |
position: relative; | |
z-index: 10; | |
} | |
&:#{$pseudo-element} { | |
background: image-url( $background-image ) repeat 0 0; | |
bottom: 0; | |
@include generated-content( auto, auto ); | |
left: 0; | |
@include opacity( $opacity ); | |
right: 0; | |
top: 0; | |
z-index: 1; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This Gist has moved into its own repository available here: https://github.com/jgarber623/compass-mixins