Last active
December 27, 2015 13:39
-
-
Save chrisslater/7334569 to your computer and use it in GitHub Desktop.
Vertically align an element within container, using the before method.
This file contains hidden or 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
// Sourced from: http://css-tricks.com/centering-in-the-unknown/ | |
@mixin element-align-center($child-element, $width-of-child) { | |
& { | |
vertical-align: middle; | |
display:inline-block; | |
} | |
&:before { | |
content: ""; | |
display: inline-block; | |
height: 100%; | |
vertical-align: middle; | |
} | |
& #{$child-element} { | |
width: $width-of-child; | |
vertical-align: middle; | |
display:inline-block; | |
padding-top: 0; | |
margin-left: -0.25em; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment