Skip to content

Instantly share code, notes, and snippets.

@timkelty
Created January 15, 2013 16:58
Show Gist options
  • Save timkelty/4540104 to your computer and use it in GitHub Desktop.
Save timkelty/4540104 to your computer and use it in GitHub Desktop.
Vertically center with inline-block and a dummy element
// Vertically center with inline-block and a dummy element
// @mixin vertically-center-child
// @see http://css-tricks.com/centering-in-the-unknown/
@mixin vertically-center-child(
$child-selector: "&:first-child",
$font-size: $base-font-size,
$collapse-white-space: if($font-size, true, false),
$dummy-selector: "&:before"
) {
@if $collapse-white-space {
font-size: 0;
}
#{$child-selector} {
@include inline-block;
@if $font-size {
font-size: $font-size;
}
}
#{$dummy-selector} {
@include inline-block;
content: "";
height: 100%;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment