Skip to content

Instantly share code, notes, and snippets.

@yannmadeleine
Created June 6, 2011 21:02
Show Gist options
  • Save yannmadeleine/1011093 to your computer and use it in GitHub Desktop.
Save yannmadeleine/1011093 to your computer and use it in GitHub Desktop.
basic functions for less
//note that in less php all ,(comma) in functions and call must be replaced by ;(semi-colon) see : http://leafo.net/lessphp/docs/#args
//handling vendor extension
.border-radius(@radius_tl: 5px, @radius_tr: 5px, @radius_br: 5px, @radius_bl: 5px) {
border-radius: @arguments;
-webkit-border-radius: @arguments;
-moz-border-radius: @arguments;
}
.top-border-radius (@radius: 5px) {
border-radius: @radius @radius 0 0;
-webkit-border-radius: @radius @radius 0 0;
-moz-border-radius: @radius @radius 0 0;
}
.box-shadow (@x: 0, @y: 0, @blur: 5px, @color: #cebdb2, @opacity : 0) {
box-shadow: @x @y @blur fadeout(@color, @opacity);
-moz-box-shadow: @x @y @blur fadeout(@color, @opacity);
-webkit-box-shadow: @x @y @blur fadeout(@color, @opacity);
.pie;
}
.horizontal_gradient (@start , @end) {
background: @start;/* Old browsers */
background: -moz-linear-gradient(top, @start 0%, @end 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,@start), color-stop(100%,@end));/* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, @start 0%,@end 100%);/* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, @start 0%,@end 100%); /* Opera11.10+ */
background: -ms-linear-gradient(top, @start 0%,@end 100%); /* IE10+ */
-pie-background: linear-gradient(@start, @end);/* IE6-9 */
background: linear-gradient(top, @start 0%,@end 100%);/* W3C */
.pie
}
.background_image(@url,@repeat:'no-repeat',@position:'left top'){
background-image:url(@url);
background-repeat : @repeat;
background-position: @position;
}
//generic functions
.center-vh(@min-height,@ratio:2.57){
font-size: @min-height / @ratio;
min-height: @min-height;
line-height: @min-height;
text-align: center;
vertical-align:middle;
}
//use () to hide from final css
.pie() {
behavior: url(/PIE.htc);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment