Created
October 16, 2014 11:06
-
-
Save dmcclintock/1d1a61f66c1a9da5bf38 to your computer and use it in GitHub Desktop.
CSS / SCSS Snippets
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
/* | |
* Vertical alignment center | |
* SRC: http://zerosixthree.se/vertical-align-anything-with-just-3-lines-of-css/ | |
* Works in IE9 | |
*/ | |
// As a mixin | |
@mixin vertical-align { | |
position: relative; | |
top: 50%; | |
-webkit-transform: translateY(-50%); | |
-ms-transform: translateY(-50%); | |
transform: translateY(-50%); | |
} | |
.element { | |
@include vertical-align; | |
} | |
// As a placeholder selector | |
%vertical-align { | |
position: relative; | |
top: 50%; | |
-webkit-transform: translateY(-50%); | |
-ms-transform: translateY(-50%); | |
transform: translateY(-50%); | |
} | |
.element p { | |
@extend %vertical-align; | |
} | |
// Half-pixel bug fix | |
.parent-element { | |
-webkit-transform-style: preserve-3d; | |
-moz-transform-style: preserve-3d; | |
transform-style: preserve-3d; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment