Last active
January 1, 2016 18:39
-
-
Save jasonhodges/8185529 to your computer and use it in GitHub Desktop.
A scss mixins file I'd like to start compiling from self-education and resources I come across while learning.
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
/* From Sass for Web Designers by Dan Cederholm (A Book Apart No.10) */ | |
@mixin rounded($radius){ | |
-webkit-border-radius: $radius; | |
-moz-border-radius: $radius; | |
border-radius: $radius; | |
} | |
@mixin shadow($x, $y, $blur, $color){ | |
-webkit-box-shadow: $x $y $blur $color; | |
-moz-box-shadow: $x $y $blur $color; | |
box-shadow: $x $y $blur $color; | |
} | |
@mixin shadow-inset($x, $y, $blur, $color){ | |
-webkit-box-shadow: inset $x $y $blur $color; | |
-moz-box-shadow: inset $x $y $blur $color; | |
box-shadow: inset $x $y $blur $color; | |
} | |
@mixin transition($property){ | |
-webkit-transition: $property .2s ease; | |
-moz-transition: $property .2s ease; | |
-o-transition: $property .2s ease; | |
transition: $property .2s ease; | |
} | |
@mixin box-sizing{ | |
-webkit-box-sizing: border-box; | |
-moz-box-sizing: border-box; | |
box-sizing: border-box; | |
} | |
@mixin linear-gradient($from, $to){ | |
/*Fallback for sad browsers */ | |
background-color: $to; | |
/* Mozilla Firefox */ | |
background-image: -moz-linear-gradient($from, $to); | |
/* Opera */ | |
background-image: -o-linear-gradient($from, $to); | |
/* Webkit (Chrome 11+) */ | |
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, $from), color-stop(1, $to)); | |
/* Webkit (Safari 5.1+, Chrome 10+) */ | |
background-image: -webkit-linear-gradient($from, $to); | |
/* IE10 */ | |
background-image: -ms-linear-gradient($from, $to); | |
/* W3C */ | |
background-image: linear-gradient($from, $to); | |
} | |
@mixin retinize($file, $type, $width, $height){ | |
background-image: url('../img/' + $file + '.' + $type); | |
@media (-webkit-min-device-pixel-ratio: 1.5), | |
(min--moz-device-pixel-ratio: 1.5), | |
(-o-min-device-pixel-ratio: 3/2), | |
(min-device-pixel-ratio: 1.5), | |
(min-resolution: 1.5dppx){ | |
&{ | |
background-image: url('../img/' + $file + '-2x.' + $type); | |
-webkit-background-size: $width $height; | |
-moz-background-size: $width $height; | |
background-size: $width $height; | |
} | |
} | |
} | |
/* retinize mixin refactored to allow code that can be easily maintained and reused */ | |
$is-hidpi:" (-webkit-min-device-pixel-ratio: 1.5), | |
(min--moz-device-pixel-ratio: 1.5), | |
(-o-min-device-pixel-ratio: 3/2), | |
(min-device-pixel-ratio: 1.5), | |
(min-resolution: 1.5dppx)"; | |
@mixin background-size($width, $height){ | |
-webkit-background-size: $width $height; | |
-moz-background-size: $width $height; | |
background-size: $width $height; | |
} | |
@mixin retinize($file, $type, $width, $height){ | |
background-image: url('../img/' + $file + '.' + $type); | |
@media #{$is-hidpi}{ | |
&{ | |
background-image: url('../img/' + $file + '-2x.' + $type); | |
@include background-size($width, $height); | |
} | |
} | |
} | |
/*From http://css-tricks.com/redesigning-with-sass/ */ | |
@mixin vendorize($property, $value) { | |
-webkit-#{$property}: $value; | |
-moz-#{$property}: $value; | |
-ms-#{$property}: $value; | |
-o-#{$property}: $value; | |
#{$property}: $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment