Created
June 16, 2014 17:52
-
-
Save DannyJoris/07f4a67eda880abb339d to your computer and use it in GitHub Desktop.
Generated by SassMeister.com.
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
<div class="parent"> | |
<div class="children child1"> | |
I'm vertically centered! | |
<br>- Fixed height in pixels (100px) | |
</div> | |
</div> | |
<div class="parent"> | |
<div class="children child2"> | |
I'm vertically centered! | |
<br>- auto height | |
</div> | |
</div> | |
<div class="parent"> | |
<div class="children child3"> | |
I'm vertically centered! | |
<br>- Fixed height larger than parent (300px) | |
</div> | |
</div> | |
<div class="parent"> | |
<div class="children child4"> | |
I'm vertically centered! | |
<br>- Height in percentage (50%) | |
</div> | |
</div> |
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
// ---- | |
// Sass (v3.3.8) | |
// Compass (v1.0.0.alpha.19) | |
// ---- | |
// From: http://davidwalsh.name/css-vertical-center | |
@import "compass"; | |
.parent { | |
width: 250px; | |
height: 250px; | |
margin: 20px; | |
border: 1px solid hotpink; | |
display: inline-block; | |
} | |
.children{ | |
background: #ffdb4c; | |
position: relative; | |
top: 50%; | |
@include translateY(-50%); | |
} | |
.child1 { | |
height: 100px; | |
} | |
.child2 { | |
height: auto; | |
} | |
.child3 { | |
height: 300px; | |
} | |
.child4 { | |
height: 50%; | |
} |
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
.parent { | |
width: 250px; | |
height: 250px; | |
margin: 20px; | |
border: 1px solid hotpink; | |
display: inline-block; | |
} | |
.children { | |
background: #ffdb4c; | |
position: relative; | |
top: 50%; | |
-moz-transform: translateY(-50%); | |
-ms-transform: translateY(-50%); | |
-webkit-transform: translateY(-50%); | |
transform: translateY(-50%); | |
} | |
.child1 { | |
height: 100px; | |
} | |
.child2 { | |
height: auto; | |
} | |
.child3 { | |
height: 300px; | |
} | |
.child4 { | |
height: 50%; | |
} |
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
<div class="parent"> | |
<div class="children child1"> | |
I'm vertically centered! | |
<br>- Fixed height in pixels (100px) | |
</div> | |
</div> | |
<div class="parent"> | |
<div class="children child2"> | |
I'm vertically centered! | |
<br>- auto height | |
</div> | |
</div> | |
<div class="parent"> | |
<div class="children child3"> | |
I'm vertically centered! | |
<br>- Fixed height larger than parent (300px) | |
</div> | |
</div> | |
<div class="parent"> | |
<div class="children child4"> | |
I'm vertically centered! | |
<br>- Height in percentage (50%) | |
</div> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment