Skip to content

Instantly share code, notes, and snippets.

Created February 13, 2013 15:48
Show Gist options
  • Save anonymous/4945545 to your computer and use it in GitHub Desktop.
Save anonymous/4945545 to your computer and use it in GitHub Desktop.
A LESS mixin I wrote awhile back that easily lets you set a container to position:absolute and center it. Usage: .some-element { .center-container(450px, 100px); }
.center-box(@width: 300px, @height: 200px) {
position:absolute;
top:50%;
left:50%;
width:@width;
height:@height;
margin-top:-(@height / 2);
margin-left:-(@width / 2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment