Skip to content

Instantly share code, notes, and snippets.

@ralexandr
Created October 19, 2016 09:13
Show Gist options
  • Save ralexandr/152b3cb45d4224cf0805dd2578c2f121 to your computer and use it in GitHub Desktop.
Save ralexandr/152b3cb45d4224cf0805dd2578c2f121 to your computer and use it in GitHub Desktop.
SASS: Align vertical+horizontal
@mixin align($vertical: true, $horizontal: false, $position: relative) {
@if $position {
position: $position;
}
@if $vertical {
top: 50%;
}
@if $horizontal {
left: 50%;
}
@if $vertical and $horizontal {
transform: translateX(-50%) translateY(-50%);
} @else if $vertical {
transform: translateY(-50%);
} @else {
transform: translateX(-50%);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment