Last active
December 20, 2015 18:49
-
-
Save tommymarshall/6178535 to your computer and use it in GitHub Desktop.
I'm using it in this content, where `.trailer__wrap` takes up the full length of the parent element, and `.trailer` element get's vertically aligned 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
%vertically-centered-child { | |
font-size: 0; | |
text-align: center; | |
&:before { | |
content: ''; | |
display: inline-block; | |
height: 100%; | |
vertical-align: middle; | |
} | |
> * { | |
display: inline-block; | |
font-size: $base-font-size; | |
vertical-align: middle; | |
} | |
} | |
/* Usage: | |
.trailer__wrap { | |
@extend %vertically-centered-child; | |
bottom: 0; | |
left: 0; | |
position: absolute; | |
right: 0; | |
top: 0; | |
} | |
.trailer { | |
// Whatever element that I want to be vertically aligned. | |
} | |
*/ | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment