Created
October 19, 2016 09:13
-
-
Save ralexandr/152b3cb45d4224cf0805dd2578c2f121 to your computer and use it in GitHub Desktop.
SASS: Align vertical+horizontal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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