Created
May 17, 2016 11:19
-
-
Save nashvail/5691f2ca43ccb74bb3f6775b9a13f4e3 to your computer and use it in GitHub Desktop.
Sass Mixin to position child in parent, relative to parent's center
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 centerer($horizontal: true, $vertical: true, $offsetH: 0%, $offsetV: 0%) { | |
position: absolute; | |
@if ($horizontal and $vertical) { | |
top: 50% + $offsetV; | |
left: 50% + $offsetH; | |
transform: translate(-50%, -50%); | |
} @else if ($horizontal) { | |
left: 50% + $offsetH; | |
transform: translate(-50%, 0); | |
} @else if ($vertical) { | |
top: 50% + $offsetV; | |
transform: translate(0, -50%); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment