Skip to content

Instantly share code, notes, and snippets.

@yacine
Last active August 29, 2015 14:17
Show Gist options
  • Save yacine/9c410639010a92a3040f to your computer and use it in GitHub Desktop.
Save yacine/9c410639010a92a3040f to your computer and use it in GitHub Desktop.
CSS / LESS alignment mixin
#align {
.horizontal(@el-width) {
left: 50%;
right: initial;
margin-left: -(@el-width/2);
}
.vertical(@el-height) {
top: 50%;
bottom: initial;
margin-top: -(@el-height/2);
}
.center (@el-width, @el-height) {
.horizontal(@el-width);
.vertical(@el-height);
}
}
// usage
.foo {
position: absolute;
#align > .center(36px, 24px);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment