Last active
February 16, 2017 01:07
-
-
Save benjamingsmith/53550e8d92a7c2b27e5e to your computer and use it in GitHub Desktop.
Center items with SASS 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
// to use: @include centerCenter; | |
// make sure the element has position: absolute, relative or fixed | |
@mixin centerCenter { | |
left: 50%; | |
top: 50%; | |
-webkit-transform: translate(-50%, -50%); | |
-ms-transform: translate(-50%, -50%); | |
transform: translate(-50%, -50%); | |
} | |
@mixin vertCenter { | |
top: 50%; | |
-webkit-transform: translateY(-50%); | |
-ms-transform: translateY(-50%); | |
transform: translateY(-50%); | |
} | |
@mixin horzCenter { | |
left: 50%; | |
-webkit-transform: translateX(-50%); | |
-ms-transform: translateX(-50%); | |
transform: translateX(-50%); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment