Created
September 21, 2011 02:04
-
-
Save peterwilsoncc/1231016 to your computer and use it in GitHub Desktop.
conditional values in LESS CSS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.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