Skip to content

Instantly share code, notes, and snippets.

@ramiabraham
Created August 9, 2013 02:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramiabraham/6190726 to your computer and use it in GitHub Desktop.
Save ramiabraham/6190726 to your computer and use it in GitHub Desktop.
just some mixins
@function black($opacity){
@return rgba(0,0,0,$opacity)
}
@function white($opacity){
@return rgba(255,255,255,$opacity)
}
@mixin box-emboss($opacity, $opacity2){
box-shadow:white($opacity) 0 1px 0, inset black($opacity2) 0 1px 0;
}
@mixin letterpress($opacity){
text-shadow:white($opacity) 0 1px 0;
}
@mixin hide-text{
overflow:hidden;
text-indent:-9000px;
display:block;
}
@mixin navigation-list {
list-style-type:none;
padding:0;
margin:0;
overflow:hidden;
> li{
display:block;
float:left;
&:last-child{
margin-right:0px;
}
}
}
// 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