Skip to content

Instantly share code, notes, and snippets.

@derryl
Created June 18, 2015 00:01
Show Gist options
  • Save derryl/7cdf9642397d68612d89 to your computer and use it in GitHub Desktop.
Save derryl/7cdf9642397d68612d89 to your computer and use it in GitHub Desktop.
Vertical alignment mixins
// Vertically center objects of dynamic size
// Note: - correct mixins must be applied to both parent and child
// - if it doesn't work, check for conflicting styles on those elements
// Apply to container element
.contain-vertically-centered-content, .contain-vc {
&:before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
margin-right: -0.25em;
}
}
// Apply to element which should be centered vertically
.vertically-center, .vc {
display: inline-block;
vertical-align: middle;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment