Created
September 10, 2012 17:31
-
-
Save Netcelal/3692347 to your computer and use it in GitHub Desktop.
10 LESS CSS Examples You Should Steal for Your Projects
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
/* Stolen from | |
* http://designshack.net/articles/css/10-less-css-examples-you-should-steal-for-your-projects/ | |
* :) | |
*/ | |
/* Mixin */ | |
.border-radius (@radius: 5px) { | |
-webkit-border-radius: @radius; | |
-moz-border-radius: @radius; | |
border-radius: @radius; | |
} | |
/* Implementation */ | |
#somediv { | |
.border-radius(20px); | |
} | |
/* Border Radius Custom Mixin */ | |
.border-radius-custom (@topleft: 5px, @topright: 5px, @bottomleft: 5px, @bottomright: 5px) { | |
-webkit-border-radius: @topleft @topright @bottomright @bottomleft; | |
-moz-border-radius: @topleft @topright @bottomright @bottomleft; | |
border-radius: @topleft @topright @bottomright @bottomleft; | |
} | |
/* Implementation */ | |
#somediv { | |
.border-radius-custom(20px, 20px, 0px, 0px); | |
} | |
/* Box Shadow Mixin */ | |
.box-shadow (@x: 0px, @y: 3px, @blur: 5px, @alpha: 0.5) { | |
-webkit-box-shadow: @x @y @blur rgba(0, 0, 0, @alpha); | |
-moz-box-shadow: @x @y @blur rgba(0, 0, 0, @alpha); | |
box-shadow: @x @y @blur rgba(0, 0, 0, @alpha); | |
} | |
/* Implementation */ | |
#somediv { | |
.box-shadow(5px, 5px, 6px, 0.3); | |
} | |
/* Transition Mixin */ | |
.transition (@prop: all, @time: 1s, @ease: linear) { | |
-webkit-transition: @prop @time @ease; | |
-moz-transition: @prop @time @ease; | |
-o-transition: @prop @time @ease; | |
-ms-transition: @prop @time @ease; | |
transition: @prop @time @ease; | |
} | |
/* Implementation */ | |
#somediv { | |
.transition(all, 0.5s, ease-in); | |
} | |
#somediv:hover { | |
opacity: 0; | |
} | |
/* Transform Mixin */ | |
.transform (@rotate: 90deg, @scale: 1, @skew: 1deg, @translate: 10px) { | |
-webkit-transform: rotate(@rotate) scale(@scale) skew(@skew) translate(@translate); | |
-moz-transform: rotate(@rotate) scale(@scale) skew(@skew) translate(@translate); | |
-o-transform: rotate(@rotate) scale(@scale) skew(@skew) translate(@translate); | |
-ms-transform: rotate(@rotate) scale(@scale) skew(@skew) translate(@translate); | |
transform: rotate(@rotate) scale(@scale) skew(@skew) translate(@translate); | |
} | |
/* Implementation */ | |
#someDiv { | |
.transform(5deg, 0.5, 1deg, 0px); | |
} | |
/* Linear Gradient Mixin */ | |
.gradient (@origin: left, @start: #ffffff, @stop: #000000) { | |
background-color: @start; | |
background-image: -webkit-linear-gradient(@origin, @start, @stop); | |
background-image: -moz-linear-gradient(@origin, @start, @stop); | |
background-image: -o-linear-gradient(@origin, @start, @stop); | |
background-image: -ms-linear-gradient(@origin, @start, @stop); | |
background-image: linear-gradient(@origin, @start, @stop); | |
} | |
/* Implementation */ | |
#someDiv { | |
.gradient(left, #663333, #333333); | |
} | |
/* Quick Gradient Mixin */ | |
.quick-gradient (@origin: left, @alpha: 0.2) { | |
background-image: -webkit-linear-gradient(@origin, rgba(0,0,0,0.0), rgba(0,0,0,@alpha)); | |
background-image: -moz-linear-gradient(@origin, rgba(0,0,0,0.0), rgba(0,0,0,@alpha)); | |
background-image: -o-linear-gradient(@origin, rgba(0,0,0,0.0), rgba(0,0,0,@alpha)); | |
background-image: -ms-linear-gradient(@origin, rgba(0,0,0,0.0), rgba(0,0,0,@alpha)); | |
background-image: linear-gradient(@origin, rgba(0,0,0,0.0), rgba(0,0,0,@alpha)); | |
} | |
/* Implementation */ | |
#somediv { | |
background-color: BADA55; | |
.quick-gradient(top, 0.2); | |
} | |
/* Webkit Reflection Mixin */ | |
.reflect (@length: 50%, @opacity: 0.2){ | |
-webkit-box-reflect: below 0px -webkit-gradient(linear, left top, left bottom, from(transparent), color-stop(@length, transparent), to(rgba(255,255,255,@opacity))); | |
} | |
/* Implementation */ | |
#somediv { | |
.reflect(20%, 0.2); | |
} | |
/* Complementary Color Scheme Mixin */ | |
@base: #663333; | |
@complement1: spin(@base, 180); | |
@complement2: darken(spin(@base, 180), 5%); | |
@lighten1: lighten(@base, 15%); | |
@lighten2: lighten(@base, 30%); | |
/* Implementation */ | |
.one {color: @base;} | |
.two {color: @complement1;} | |
.three {color: @complement2;} | |
.four {color: @lighten1;} | |
.five {color: @lighten2;} | |
/* Subtle Color Scheme Mixin */ | |
@base: #663333; | |
@lighter1: lighten(spin(@base, 5), 10%); | |
@lighter2: lighten(spin(@base, 10), 20%); | |
@darker1: darken(spin(@base, -5), 10%); | |
@darker2: darken(spin(@base, -10), 20%); | |
/* Implementation */ | |
.one {color: @base;} | |
.two {color: @lighter1;} | |
.three {color: @lighter2;} | |
.four {color: @darker1;} | |
.five {color: @darker2;} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment