Last active
October 23, 2017 11:37
-
-
Save gabskoro/f90e648a09168bc4d1d33412d1078cb6 to your computer and use it in GitHub Desktop.
CSS vertical aligns using ::after pseudo element on the parent
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
// Resource https://medium.com/@hayavuk/vertically-center-variable-height-elements-inside-a-container-using-css-2a2aa9dbe032 | |
// NOTE: this doesn't work with min-height set on the parent | |
@mixin vc-parent() { | |
white-space: nowrap; | |
&:after { | |
content: ''; | |
display: inline-block; | |
height: 100%; | |
vertical-align: middle; | |
width: 0; | |
} | |
} | |
@mixin vc-child() { | |
display: inline-block; | |
vertical-align: middle; | |
white-space: normal; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment