Is there a way to ensure equal height for all children using flexbox, but also have a fallback option for browsers like IE10 and similar?
I tried using display: table
and display: table-cell
, but it doesn't seem to work well with fixed heights. Additionally, table-layout: fixed
only sizes based on the first cell's height if it is the largest.
html {
box-sizing: border-box;
}
*,
:after,
:before {
box-sizing: inherit;
}
.wrap {
padding-left: 16px;
padding-right: 16px;
}
.gel-layout {
list-style: none;
direction: ltr;
text-align: left;
margin-right: 0;
margin-left: -8px;
padding-right: 0;
padding-left: 0;
}
.gel-layout--equal {
display: table;
table-layout: fixed;
width: 100%;
}
.gel-1\/3 {
width: 33.33333333%!important;
}
.gel-layout__item {
width: 100%;
display: inline-block;
padding-left: 8px;
text-align: left;
vertical-align: top;
}
.gel-layout--equal>.gel-layout__item {
display: table-cell;
}
.gel-c-grid-demo-item {
width: 100%;
padding: 8px;
background-color: #d4e7eb;
color: #121212;
}
.gel-c-grid-demo-item--auto {
height: auto;
}
.gel-c-grid-demo-item--fill {
background: repeating-linear-gradient(180deg, #d4e7eb, #d4e7eb 8px, #aec4cc 0, #aec4cc 16px);
}
.gel-c-grid-demo-item--first {
height: 72px;
}
.gel-c-grid-demo-item--large {
height: 144px;
}
<div class="wrap">
<div>
<h2>Equal Height</h2>
<div class="gel-layout gel-layout--equal">
<div class="gel-layout__item gel-1/3 left">
<div class="gel-c-grid-demo-item gel-c-grid-demo-item--auto gel-c-grid-demo-item--fill gel-c-grid-demo-item gel-c-grid-demo-item--first">one</div>
</div>
<div class="gel-layout__item gel-1/3">
<div class="gel-c-grid-demo-item gel-c-grid-demo-item--fill">two</div>
</div>
<div class="gel-layout__item gel-1/3">
<div class="gel-c-grid-demo-item gel-c-grid-demo-item--large gel-c-grid-demo-item--fill">three</div>
</div>
</div>
</div>
</div>