Skip to content

Instantly share code, notes, and snippets.

@peterwilsoncc
Created September 21, 2011 02:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterwilsoncc/1231016 to your computer and use it in GitHub Desktop.
Save peterwilsoncc/1231016 to your computer and use it in GitHub Desktop.
conditional values in LESS CSS
.gradient(@start: #dddddd, @end: #ffffff, @background: 'set to start') {
//awful code - less can't access outer scope
@s: @start;
@b: @background;
background-color: ~`(this.b.toJS() == "'set to start'")?this.s.toJS():this.b.toJS()`;
background-image: -moz-linear-gradient(top, @start, @end);
background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, @start),color-stop(1, @end));
background-image: linear-gradient(top, @start, @end);
filter: e(%("progid:DXImageTransform.Microsoft.gradient(startColorStr='%d', EndColorStr='%d')", @start, @end));
}
body {
.gradient(#000, #fff);
/*
with background colour
*/
.gradient(#000, #fff, #f00);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment