Skip to content

Instantly share code, notes, and snippets.

@roscabgdn
Created March 2, 2016 07:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roscabgdn/f2da0a35b57427723147 to your computer and use it in GitHub Desktop.
Save roscabgdn/f2da0a35b57427723147 to your computer and use it in GitHub Desktop.
/*
* @seen on https://css-tricks.com/snippets/sass/centering-mixin/
*/
@mixin center($horizontal: true, $vertical: true) {
position: absolute;
@if ($horizontal and $vertical) {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
} @else if ($horizontal) {
left: 50%;
transform: translate(-50%, 0);
} @else if ($vertical) {
top: 50%;
transform: translate(0, -50%);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment