Skip to content

Instantly share code, notes, and snippets.

@tjoskar
Last active December 22, 2015 06:08
Show Gist options
  • Save tjoskar/6428544 to your computer and use it in GitHub Desktop.
Save tjoskar/6428544 to your computer and use it in GitHub Desktop.
Help functions for less
// Var
@imgPath: 'http://exampel.com/img/';
@darkGray: #333;
@gray: #4f4f4f;
@lightGray: #CCC;
@green: #03A37E;
@font: 'Open Sans', sans-serif;
// Functions
.border-radius (@radius: 5px) {
border-radius: @radius;
-moz-border-radius: @radius;
-webkit-border-radius: @radius;
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
background-clip: padding-box;
}
.box-shadow (@x: 0, @y: 0, @blur: 0, @color: #fff) {
box-shadow: @arguments;
-moz-box-shadow: @arguments;
-webkit-box-shadow: @arguments;
}
.text-shadow (@x: 1px, @y: -1px, @blur: 0, @color: #fff) {
text-shadow: @arguments;
}
.ease-transition (@s: 0.5s) {
-webkit-transition: all @s ease-out;
-moz-transition: all @s ease-out;
-ms-transition: all @s ease-out;
-o-transition: all @s ease-out;
transition: all @s ease-out;
}
.animation(@args) {
-webkit-animation: @args;
-moz-animation: @args;
-ms-animation: @args;
}
.background-size(@args) {
-webkit-background-size: @args;
-moz-background-size: @args;
background-size: @args;
}
.border-radius(@args) {
-webkit-border-radius: @args;
-moz-border-radius: @args;
border-radius: @args;
-webkit-background-clip: padding-box;
-moz-background-clip: padding;
background-clip: padding-box;
}
.box-shadow(@args) {
-webkit-box-shadow: @args;
-moz-box-shadow: @args;
box-shadow: @args;
}
.inner-shadow(@args) {
.box-shadow(inset @args);
}
.transform(@args) {
-webkit-transform: @args;
-moz-transform: @args;
-ms-transform: @args;
-o-transform: @args;
transform: @args;
}
.rotate(@deg: 45deg) {
.transform(rotate(@deg));
}
.scale(@factor: .5) {
.transform(scale(@factor));
}
.translate(@x, @y) {
.transform(translate(@x, @y));
}
.translate3d(@x, @y, @z) {
.transform(translate3d(@x, @y, @z));
}
.translateHardware(@x, @y) {
.translate(@x, @y);
-webkit-transform: translate3d(@x, @y, 0);
-moz-transform: translate3d(@x, @y, 0);
}
.transition(@args) {
-webkit-transition: @args;
-moz-transition: @args;
-o-transition: @args;
transition: @args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment