Skip to content

Instantly share code, notes, and snippets.

@gabskoro
Last active October 23, 2017 11:37
Show Gist options
  • Save gabskoro/f90e648a09168bc4d1d33412d1078cb6 to your computer and use it in GitHub Desktop.
Save gabskoro/f90e648a09168bc4d1d33412d1078cb6 to your computer and use it in GitHub Desktop.
CSS vertical aligns using ::after pseudo element on the parent
// 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