Skip to content

Instantly share code, notes, and snippets.

@jehoshua02
Created December 12, 2014 11:36
Show Gist options
  • Save jehoshua02/5d706862a2a31cfe45d6 to your computer and use it in GitHub Desktop.
Save jehoshua02/5d706862a2a31cfe45d6 to your computer and use it in GitHub Desktop.
Sass button mixins. The color and sizing properties separated to make it convenient for defining button modifiers without redefining the whole button.
@mixin button-common() {
border: 0 none;
color: #fff;
display: inline-block;
text-align: center;
cursor: pointer;
vertical-align: baseline;
text-decoration: none;
&:active,
&--active {
outline: none;
}
}
@mixin button-color($color) {
background-color: $color;
&:hover,
&--hover {
background-color: darken($color, 3%);
}
&:active,
&--active {
background-color: darken($color, 8%);
}
}
@mixin button-size($height) {
height: $height;
line-height: $height;
border-radius: $height * ($input-border-radius / $input-height);
font-size: $height * ($font-size-default / $input-height);
$padding: $height * ($input-padding / $input-height);
padding: 0 $padding;
}
@mixin button($color: $orange, $height: $input-height) {
@include button-common();
@include button-color($color);
@include button-size($height);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment