Skip to content

Instantly share code, notes, and snippets.

@bpainter
Created April 16, 2013 12:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bpainter/5395417 to your computer and use it in GitHub Desktop.
Save bpainter/5395417 to your computer and use it in GitHub Desktop.
A CodePen by Bermon Painter. Control Directives - if, else if, else
<h1>Control Directives - if, else if, else</h1>
<p>One of the features that makes Sass more robust that other preprocessors is the wide variety of control directives.</p>
<button type="submit">Submit to our will</button>
<button type="reset">Start Over</button>
<button class="cancel">Give Up</button>
@import "compass";
h1 {
font-size: 20px;
}
%button {
background-color: none;
border-width: 1px;
border-style: solid;
display: inline-block;
margin: 0 5px;
padding: 12px 24px;
}
@mixin button ($color, $type) {
@extend %button;
border-color: darken($color, 20%);
border-radius: 4px;
color: lighten($color, 60%);
@if $type == "flat" {
background-color: $color;
} @else if $type == "glossy" {
background-image: linear-gradient(lighten($color, 10%) 50%, darken($color, 10%) 50%);
} @else if $type == "gradient" {
background-image: linear-gradient(lighten($color, 10%), darken($color, 10%));
}
}
button[type="submit"] {
@include button(green, gradient);
}
button[type="reset"] {
@include button(#999, flat);
}
button.cancel {
@include button(red, glossy);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment