I\'m using flexbox columns for a pretty basic layout. There is a header, image and a list below. List must have a border and can have varying contents. Is it possible to hav
Since both columns are inside the same flex container, yes, the list boxes can be the same height (based on the tallest content) using only CSS.
.columns {
display: flex;
}
.col {
display: flex; /* new */
flex-direction: column; /* new */
margin-left: 20px;
}
.list {
flex: 1; /* new */
padding: 24px;
border: 1px solid blue;
}
ul {
margin: 0;
}
<div class="columns">
<div class="col">
<h3>Header</h3>
<div class="list">
<ul>
<li>List item</li>
<li>List item</li>
</ul>
</div>
</div>
<div class="col">
<h3>Header</h3>
<div class="list">
<ul>
<li>List item</li>
<li>List item</li>
<li>List item</li>
<li>List item</li>
</ul>
</div>
</div>
</div>
Here are a few more examples:
jsFiddle demo
.columns {
display: flex;
}
.col {
display: flex; /* new */
flex-direction: column; /* new */
margin-left: 20px;
}
.list {
flex: 1; /* new */
padding: 24px;
border: 1px solid blue;
}
ul {
margin: 0;
}
<div class="columns">
<div class="col">
<h3>Header</h3>
<div class="list">
<ul>
<li>List item</li>
<li>List item</li>
</ul>
</div>
</div>
<div class="col">
<h3>Header</h3>
<div class="list">
<ul>
<li>List item</li>
<li>List item</li>
<li>List item</li>
<li>List item</li>
</ul>
</div>
</div>
</div>
<br>
<div class="columns">
<div class="col">
<h3>Header</h3>
<div class="list">
<ul>
<li>List item</li>
<li>List item</li>
</ul>
</div>
</div>
<div class="col">
<h3>Header</h3>
<div class="list">
<ul>
<li>List item</li>
<li>List item</li>
<li>List item</li>
<li>List item</li>
<li>List item</li>
<li>List item</li>
<li>List item</li>
<li>List item</li>
</ul>
</div>
</div>
</div>
<br>
<div class="columns">
<div class="col">
<h3>Header</h3>
<div class="list">
<ul>
<li>List item</li>
<li>List item</li>
<li>List item</li>
<li>List item</li>
<li>List item</li>
<li>List item</li>
<li>List item</li>
<li>List item</li>
</ul>
</div>
</div>
<div class="col">
<h3>Header</h3>
<div class="list">
<ul>
<li>List item</li>
<li>List item</li>
</ul>
</div>
</div>
</div>
You should set .col as flex too
.col{
display:flex;
}
and your class columns is better named row