A Pen by Le Roux Bodenstein on CodePen.
Created
August 20, 2015 03:05
-
-
Save kirushik/70a105c957ff157f8261 to your computer and use it in GitHub Desktop.
Testing 100vh and flexbox
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="fullscreen"> | |
<div class="top">top</div> | |
<div class="middle"> | |
<div class="left">left</div> | |
<div class="center">center</div> | |
<div class="right">right</div> | |
</div> | |
<div class="bottom">bottom</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
/* | |
* IE11 unnecessarily adds a vertical scrollbar. (Somehow there's an extra pixel vertically.) | |
* IE11 overlaps the middle and bottom parts once you nest two flexbox containers and you don't explicitly move them apart by setting a height. (comment out height: 100vh to see top and bottom get displayed on top of each other) | |
* If you specify a min-height on the outer container, IE11 does mostly the same thing. | |
*/ | |
html, | |
body { | |
min-height: 100%; | |
} | |
.fullscreen { | |
height: 100vh; | |
background-color: #ccc; | |
display: flex; | |
flex-direction: column; | |
} | |
.top, .middle, .bottom { | |
background-color: #aaa; | |
width: 100%; | |
text-align: center; | |
} | |
.middle { | |
flex: 1; | |
display: flex; | |
margin: 10px 0; | |
} | |
.center { | |
flex: 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment