Skip to content

Instantly share code, notes, and snippets.

@linuslundahl
Forked from simme/_mixins.sass
Last active October 27, 2015 09:37
Show Gist options
  • Save linuslundahl/1551088 to your computer and use it in GitHub Desktop.
Save linuslundahl/1551088 to your computer and use it in GitHub Desktop.
SASS Mixins and Functions
// Rounds all the corners of a box
@mixin vector-bg-with-fallback($name) {
background-image: image-url('#{$name}.png');
background-image: none, image-url('#{$name}.svg');
}
@mixin border-radius($radius, $clip: padding-box)
-webkit-border-radius: $radius
-moz-border-radius: $radius
-o-border-radius: $radius
border-radius: $radius
-webkit-background-clip: $clip
-mox-background-clip: $clip
-o-background-clip: $clip
background-clip: $clip
// Rounds a box's corners on one side
@mixin border-radius-side($radius, $side, $clip: padding-box)
@if $side == 'top' or $side == 'bottom'
-webkit-border-#{$side}-left-radius: $radius
-webkit-border-#{$side}-right-radius: $radius
@else
-webkit-border-top-#{$side}-radius: $radius
-webkit-border-bottom-#{$side}-radius: $radius
-webkit-background-clip: $clip
-mox-background-clip: $clip
-o-background-clip: $clip
background-clip: $clip
// Creates a linear gradient between two colors
@mixin linear-gradient($from, $to)
background-color: $to
background-image: -moz-linear-gradient($from, $to)
background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, $from),color-stop(1, $to))
background-image: -webkit-linear-gradient($from, $to)
background-image: -o-linear-gradient($from, $to)
background-image: linear-gradient($from, $to)
// Adds shadow to a box
@mixin box-shadow($arguments)
-moz-box-shadow: $arguments
-o-box-shadow: $arguments
-webkit-box-shadow: $arguments
box-shadow: $arguments
// Adds shadow to text
@mixin text-shadow($arguments)
-moz-text-shadow: $arguments
-o-text-shadow: $arguments
-webkit-text-shadow: $arguments
text-shadow: $arguments
// Add transitions
@mixin transition($args)
-webkit-transition: $args
-moz-transition: $args
transition: $args
// Rotate the object the given number of degrees
@mixin rotate($angle)
-webkit-transform: rotate($angle)
-moz-transform: rotate($angle)
-o-transform: rotate($angle)
transform: rotate($angle)
// Creates the illusion of "lifted" corners
@mixin bendy-shadow($width, $angle: 5deg, $color: rgba(#333, 0.5))
position: relative
z-index: 1
@include box-shadow(0 7px 5px -5px $color)
&:before, &:after
content: ""
position: absolute
bottom: 6px
width: $width / 2
height: 10px
z-index: -1
@include box-shadow(0 10px 10px 1px $color)
&:before
left: 0px
@include rotate(-$angle)
&:after
right: 0px
@include rotate($angle)
// Convert px to em
@function pxtoem($target, $context)
@return ($target/$context) + 0em
// Convert em to px
@function emtopx($target, $context)
@return ($target*$context) + 0px
@Leagnus
Copy link

Leagnus commented Oct 27, 2015

"-mox" should be "-moz"

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