Skip to content

Instantly share code, notes, and snippets.

@courtsimas
Created September 3, 2011 02:19
Show Gist options
  • Save courtsimas/1190428 to your computer and use it in GitHub Desktop.
Save courtsimas/1190428 to your computer and use it in GitHub Desktop.
sass mixins
@mixin gradient($first, $second, $colorstop:0) {
background: $first;
background: -webkit-gradient(linear, left top, left bottom, from($first), color-stop($colorstop, $first), to($second));
background: -moz-linear-gradient(top, $first $colorstop, $second);
}
@mixin border-gradient($first, $second, $colorstop:0) {
border-color:$first;
border-style:double;
-webkit-border-image: -webkit-gradient(linear, 0 100%, 0 0, from($first), to($second)) 1 100%;
}
@mixin box-shadow($first, $second:0){
@if( $second == 0 ) {
-moz-box-shadow: $first;
-webkit-box-shadow: $first;
box-shadow: $first;
}@else{
-moz-box-shadow: $first, $second;
-webkit-box-shadow: $first, $second;
box-shadow: $first, $second;
}
}
@mixin border-radius($radius) {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
border-radius: $radius;
}
@mixin oswald {
font-weight:normal;
font-family:'Oswald', Helvetica, Arial, Sans-serif;
}
@mixin helvetica {
font-weight:normal;
font-family:Helvetica, Arial, Sans-serif;
}
@mixin georgia {
font-style:italic;
font-family: Georgia, Arial Serif;
}
@mixin box-sizing {
-moz-box-sizing:border-box;
-webkit-box-sizing: border-box;
box-sizing:border-box;
}
@mixin radius-circle {
@include border-radius(150px);
}
@mixin media_query($type, $filename, $background-size) {
@if $type == max {
@media only screen and (-webkit-max-device-pixel-ratio: 1.5),
only screen and (max--moz-device-pixel-ratio: 1.5),
only screen and (-o-max-device-pixel-ratio: 3/2),
only screen and (max-device-pixel-ratio: 1.5) {
background:image_url($filename) no-repeat;
-webkit-background-size:$background-size;
background-size:$background-size;
}
}
@if $type == min {
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min--moz-device-pixel-ratio: 1.5),
only screen and (-o-min-device-pixel-ratio: 3/2),
only screen and (min-device-pixel-ratio: 1.5) {
background:image_url($filename) no-repeat;
-webkit-background-size:$background-size;
background-size:$background-size;
}
}
}
@courtsimas
Copy link
Author

example:
@include media_query(max, "sprite_types_small.png", 367px 55px);
@include media_query(min, "[email protected]", 367px 55px);

or
$tab-green: rgb(68,114,114);
@include gradient($tab-green, darken($tab-green, 15%), 50%);

@courtsimas
Copy link
Author

or
@include border-gradient(rgba(54, 63, 58, .5), rgba(54, 63, 58, .1));
@include box-shadow(rgba(0, 0, 0, 0.45) 0 4px 16px 0 inset, rgba(255,255,255, 0.25) 0 1px 1px 0);
@include border-gradient(rgba(54, 63, 58, .1), rgba(54, 63, 58, 1));

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment