1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-08-29 16:49:58 +02:00

feat: Same height columns

This commit is contained in:
Phuoc Nguyen
2022-09-21 13:22:25 +07:00
parent 0482cc69f0
commit 8fd823a570
7 changed files with 92 additions and 193 deletions

View File

@@ -0,0 +1,9 @@
<div class="same-height-columns">
{% for i in range(0, 3) -%}
<div class="same-height-columns__column">
{% rectangle "hor", "md", 100 %}
<div class="same-height-columns__content">{% lines "hor", (i + 1) * 4 %}</div>
{% rectangle "hor" %}
</div>
{%- endfor %}
</div>

View File

@@ -112,6 +112,7 @@ eleventyExcludeFromCollections: true
{% pattern "Card layout" %}{% include "patterns/card-layout.njk" %}{% endpattern %}
{% pattern "Holy grail" %}{% include "patterns/holy-grail.njk" %}{% endpattern %}
{% pattern "Masonry grid" %}{% include "patterns/masonry-grid.njk" %}{% endpattern %}
{% pattern "Same height columns" %}{% include "patterns/same-height-columns.njk" %}{% endpattern %}
</div>
</div>

View File

@@ -0,0 +1,54 @@
---
layout: layouts/post.njk
title: Same height columns
description: Create same height columns with CSS flexbox
keywords: css flexbox, css layout, css same height columns
---
## HTML
```html
<div class="same-height-columns">
<!-- Column -->
<div class="same-height-columns__column">
<!-- Cover -->
...
<!-- Content -->
<div class="same-height-columns__content">
...
</div>
<!-- Button sticks to the bottom -->
...
</div>
<!-- Repeat with other columns -->
...
</div>
```
## CSS
```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;
}
```
{% demo %}{% include "patterns/same-height-columns.njk" %}{% enddemo %}