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:
9
contents/_includes/patterns/same-height-columns.njk
Normal file
9
contents/_includes/patterns/same-height-columns.njk
Normal 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>
|
@@ -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>
|
||||
|
||||
|
54
contents/same-height-columns.md
Normal file
54
contents/same-height-columns.md
Normal 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 %}
|
Reference in New Issue
Block a user