Created
November 30, 2017 08:59
-
-
Save yowainwright/3be159d7211578627fa2a70224956587 to your computer and use it in GitHub Desktop.
Useful SCSS Positioning Mixins
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
// vertically center | |
@mixin vertical-align($position: relative) { | |
position: $position; | |
top: 50%; | |
transform: translateY(-50%); | |
} | |
// Example usage: @include vertical-align; | |
// horizontally align | |
@mixin horizontal-align($position: relative) { | |
position: $position; | |
left: 50%; | |
transform: translateX(-50%); | |
} | |
// Example usage: @include horizontal-align; | |
// middle align (vertically & horizontally center) | |
@mixin middle-align($position: absolute) { | |
left: 50%; | |
position: $position; | |
top: 50%; | |
transform: translate(-50%, -50%); | |
} | |
// Example usage: @include middle-align; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment