There is a longstanding issue with Internet Explorer 11 and flexbox that a unit must be declared with flex, e.g.
/* Works */
flex: 1 0 0%;
/* Does not work */
flex: 1 0 0;
The workaround would be to specify a unit for the ending zero - preferably %
because minifiers don't usually remove that unit.
Unfortunately, I am working with Prepros (SCSS compiler) and I use the built-in CSS minifier that decides to remove the percentage anyway. I had thought this would only give me issues in IE 11, but now I have noticed that the issue is also seen in all other major browsers (tested on Edge, FF, Chrome).
Take the code below. I expect the main element (green) to grow to accommodate for its contents, but it does not. At least not when using a unitless value. If you change flex
to 1 0 0%
for main, everything works as expected. Why is that?
html,
body {
width: 100%;
height: 100%;
}
.container {
width: 100%;
height: 100%;
min-height: 240px;
background: white;
display: flex;
flex-direction: column;
overflow: hidden;
}
header {
background: red;
height: 120px;
padding: 12px;
}
main {
background: green;
display: flex;
overflow: scroll;
align-items: center;
flex: 1 0 0;
}
footer {
background: blue;
height: 80px;
}
<div class="page-wrapper">
<!-- more HTML elements -->
<div class="container">
<header></header>
<main>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi. Nulla quis sem at nibh elementum imperdiet. Duis sagittis ipsum. Praesent mauris. Fusce nec tellus sed augue semper
porta. Mauris massa. Vestibulum lacinia arcu eget nulla. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Curabitur sodales ligula in libero. Sed dignissim lacinia nunc. </p>
<p>Curabitur tortor. Pellentesque nibh. Aenean quam. In scelerisque sem at dolor. Maecenas mattis. Sed convallis tristique sem. Proin ut ligula vel nunc egestas porttitor. Morbi lectus risus, iaculis vel, suscipit quis, luctus non, massa. Fusce ac
turpis quis ligula lacinia aliquet. Mauris ipsum. Nulla metus metus, ullamcorper vel, tincidunt sed, euismod in, nibh. Quisque volutpat condimentum velit. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos.
Nam nec ante. </p>
</main>
<footer></footer>
</div>
</div>