Created
January 15, 2013 16:58
-
-
Save timkelty/4540104 to your computer and use it in GitHub Desktop.
Vertically center with inline-block and a dummy element
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
// 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