--- category: Layout created: '2019-11-17' description: Create same height columns with CSS flexbox keywords: css flexbox, css layout, css same height columns thumbnail: /assets/css-layout/thumbnails/same-height-columns.png title: Same height columns --- ## HTML ```html index.html
...
...
...
...
``` ## CSS ```css styles.css .same-height-columns { display: flex; } .same-height-columns__column { flex: 1; /* Space between columns */ margin: 0 8px; /* Layout each column */ display: flex; flex-direction: column; } .same-height-columns__content { /* Take available height */ flex: 1; } ``` ```css placeholders.css hidden .lines { padding: 0.25rem 0; width: 100%; align-items: center; display: flex; justify-content: center; flex-direction: column; } .line { background: #d1d5db; height: 1px; margin-bottom: 0.25rem; } .line.line--20 { width: 20%; } .line.line--40 { width: 40%; } .line.line--60 { width: 60%; } .line.line--80 { width: 80%; } .line.line--100 { width: 100%; } ``` ```css styles.css hidden body { height: 24rem; } .same-height-columns { display: flex; /* Demo */ width: 100%; height: 100%; } .same-height-columns__column { flex: 1; /* Space between columns */ margin: 0 0.25rem; /* Layout each column */ display: flex; flex-direction: column; /* Demo */ border: 1px solid #d1d5db; border-radius: 0.25rem; padding: 0.25rem; } .same-height-columns__content { /* Take available height */ flex: 1; } ``` ```html index.html hidden
```