Skip to content

Instantly share code, notes, and snippets.

@jamesfinley
Created June 27, 2011 20:58
Show Gist options
  • Select an option

  • Save jamesfinley/1049823 to your computer and use it in GitHub Desktop.

Select an option

Save jamesfinley/1049823 to your computer and use it in GitHub Desktop.
Mixins
@mixin position($top: false, $left: false, $bottom: false, $right: false) {
position: absolute;
@if type_of($top) == number {
top: $top;
}
@if type_of($left) == number {
left: $left;
}
@if type_of($bottom) == number {
bottom: $bottom;
}
@if type_of($right) == number {
right: $right;
}
}
// Examples
#my_div {
@include position($top: 0, $right: 0); //set any side distance
}
@mixin border-radius($radius: false, $topleft: false, $topright: false, $bottomright: false, $bottomleft: false) {
@if type_of($radius) == number {
-webkit-border-radius: $radius;
-moz-border-radius: $radius;
border-radius: $radius;
}
@if type_of($topleft) == number {
-webkit-border-top-left-radius: $topleft;
-moz-border-radius-topleft: $topleft;
border-top-left-radius: $topleft;
}
@if type_of($topright) == number {
-webkit-border-top-right-radius: $topright;
-moz-border-radius-topright: $topright;
border-top-right-radius: $topright;
}
@if type_of($bottomright) == number {
-webkit-border-bottom-right-radius: $bottomright;
-moz-border-radius-bottomright: $bottomright;
border-bottom-right-radius: $bottomright;
}
@if type_of($bottomleft) == number {
-webkit-border-bottom-left-radius: $bottomleft;
-moz-border-radius-bottomleft: $bottomleft;
border-bottom-left-radius: $bottomleft;
}
}
// Examples
#my_div {
@include border-radius(20px); //set all corners
}
#my_div {
@include border-radius($topleft: 20px); //set any of the specific corners
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment