Last active
January 7, 2016 14:58
-
-
Save maxxscho/18618c22dca0e21c6a2a to your computer and use it in GitHub Desktop.
Centering the unknown
This file contains hidden or 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
// Center a block element width unknown | |
// height and width horizontally and vertically | |
// If it doesn't center vertically, play with the spacing. | |
// <div class="parent"> | |
// <div class="child">....</div> | |
// </div> | |
// | |
// .parent { | |
// ... your styles here.... | |
// text-align:center; // if you need horizontally spacing | |
// @include center-vertical; | |
// } | |
// | |
// .child { | |
// .... your styles here | |
// } | |
@mixin center-vertical($spacing: -0.25em) { | |
&:before { | |
content: ''; | |
display: inline-block; | |
height: 100%; | |
vertical-align: middle; | |
margin-right: $spacing; | |
} | |
> * { | |
display: inline-block; | |
vertical-align: middle; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment