Created
November 9, 2011 00:02
-
-
Save stephenparish/1349792 to your computer and use it in GitHub Desktop.
Less.js CSS Functions, some common short-hands I use to make my life easier.
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
// add rounded corners to an item | |
.border-radius (@radius: 5px) { | |
-webkit-border-radius: @radius; | |
-moz-border-radius: @radius; | |
border-radius: @radius; | |
} | |
// add only specific rounded corners | |
.border-radius-all (@top: 5px, @right: 5px, @bottom: 5px, @left: 5px) { | |
-webkit-border-radius: @arguments; | |
-moz-border-radius: @arguments; | |
border-radius: @arguments; | |
} | |
// rotate an element | |
.rotate (@deg: 90deg) { | |
-webkit-transform: rotate(@deg); | |
-moz-transform: rotate(@deg); | |
-ms-transform: rotate(@deg); | |
-o-transform: rotate(@deg); | |
transform: rotate(@deg); | |
} | |
// set a gradient background | |
.gradient (@start: #92bf42, @stop: #628b1d) { | |
background: @start; /* Old browsers */ | |
background: -moz-linear-gradient(top, @start 0%, @stop 100%); /* FF3.6+ */ | |
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,@start), color-stop(100%,@stop)); /* Chrome,Safari4+ */ | |
background: -webkit-linear-gradient(top, @start 0%,@stop 100%); /* Chrome10+,Safari5.1+ */ | |
background: -o-linear-gradient(top, @start 0%,@stop 100%); /* Opera11.10+ */ | |
background: -ms-linear-gradient(top, @start 0%,@stop 100%); /* IE10+ */ | |
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='@start', endColorstr='@stop',GradientType=0 ); /* IE6-9 */ | |
background: linear-gradient(top, @start 0%,@stop 100%); /* W3C */ | |
} | |
// shadow effects -- only exterior | |
.box-shadow (@x: 0, @y: 0, @blur: 1px, @spread: 0, @color) { | |
box-shadow: @arguments; | |
-moz-box-shadow: @arguments; | |
-o-box-shadow: @arguments; | |
-webkit-box-shadow: @arguments; | |
} | |
// shadow effects -- only inset | |
.box-shadow-inset (@x: 0, @y: 0, @blur: 1px, @spread: 0, @color) { | |
box-shadow: @arguments inset; | |
-moz-box-shadow: @arguments inset; | |
-o-box-shadow: @arguments inset; | |
-webkit-box-shadow: @arguments inset; | |
} | |
// shadow effects -- use both at the same time | |
.box-shadow-both (@x_out: 0, @y_out: 0, @blur_out: 1px, @spread_out: 0, @color_out, @x_in, @y_in, @blur_in, @spread_in, @color_in) { | |
box-shadow: @arguments inset; | |
-moz-box-shadow: @arguments inset; | |
-o-box-shadow: @arguments inset; | |
-webkit-box-shadow: @arguments inset; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment