mirror of
https://github.com/phuoc-ng/csslayout.git
synced 2025-08-30 00:59:47 +02:00
feat: Simple grid
This commit is contained in:
15
contents/_includes/patterns/simple-grid.njk
Normal file
15
contents/_includes/patterns/simple-grid.njk
Normal file
@@ -0,0 +1,15 @@
|
||||
<div class="simple-grid">
|
||||
<div class="simple-grid__cell simple-grid__cell--1/4">{% rectangle "hor", "md", 100 %}</div>
|
||||
<div class="simple-grid__cell simple-grid__cell--fill">{% rectangle "hor", "md", 100 %}</div>
|
||||
</div>
|
||||
<div class="simple-grid">
|
||||
<div class="simple-grid__cell simple-grid__cell--1/3">{% rectangle "hor", "md", 100 %}</div>
|
||||
<div class="simple-grid__cell simple-grid__cell--1/3">{% rectangle "hor", "md", 100 %}</div>
|
||||
<div class="simple-grid__cell simple-grid__cell--1/3">{% rectangle "hor", "md", 100 %}</div>
|
||||
</div>
|
||||
<div class="simple-grid">
|
||||
<div class="simple-grid__cell simple-grid__cell--1/4">{% rectangle "hor", "md", 100 %}</div>
|
||||
<div class="simple-grid__cell simple-grid__cell--1/4">{% rectangle "hor", "md", 100 %}</div>
|
||||
<div class="simple-grid__cell simple-grid__cell--1/4">{% rectangle "hor", "md", 100 %}</div>
|
||||
<div class="simple-grid__cell simple-grid__cell--1/4">{% rectangle "hor", "md", 100 %}</div>
|
||||
</div>
|
@@ -114,6 +114,7 @@ eleventyExcludeFromCollections: true
|
||||
{% pattern "Masonry grid" %}{% include "patterns/masonry-grid.njk" %}{% endpattern %}
|
||||
{% pattern "Same height columns" %}{% include "patterns/same-height-columns.njk" %}{% endpattern %}
|
||||
{% pattern "Sidebar" %}{% include "patterns/sidebar.njk" %}{% endpattern %}
|
||||
{% pattern "Simple grid" %}{% include "patterns/simple-grid.njk" %}{% endpattern %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
54
contents/simple-grid.md
Normal file
54
contents/simple-grid.md
Normal file
@@ -0,0 +1,54 @@
|
||||
---
|
||||
layout: layouts/post.njk
|
||||
title: Simple grid
|
||||
description: Create a simple grid with CSS flexbox
|
||||
keywords: css flexbox, css flexbox grid, css grid, css layout
|
||||
---
|
||||
|
||||
## HTML
|
||||
|
||||
```html
|
||||
<!-- Row -->
|
||||
<div class="simple-grid">
|
||||
<!--Cell with given width. Replace 25% with whatever you want -->
|
||||
<div class="simple-grid__cell simple-grid__cell--1/4">25%</div>
|
||||
|
||||
<!-- Cell that takes remaining width -->
|
||||
<div class="simple-grid__cell simple-grid__cell--fill">
|
||||
...
|
||||
</div>
|
||||
</div>
|
||||
```
|
||||
|
||||
## CSS
|
||||
|
||||
```css
|
||||
.simple-grid {
|
||||
display: flex;
|
||||
|
||||
margin-left: -0.25rem;
|
||||
margin-right: -0.25rem;
|
||||
}
|
||||
|
||||
.simple-grid__cell {
|
||||
padding-left: 0.25rem;
|
||||
padding-right: 0.25rem;
|
||||
}
|
||||
|
||||
.simple-grid__cell--fill {
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
/* Cell with given width */
|
||||
.simple-grid__cell--1\/2 {
|
||||
flex: 0 0 50%;
|
||||
}
|
||||
.simple-grid__cell--1\/3 {
|
||||
flex: 0 0 33.3333333%;
|
||||
}
|
||||
.simple-grid__cell--1\/4 {
|
||||
flex: 0 0 25%;
|
||||
}
|
||||
```
|
||||
|
||||
{% demo %}{% include "patterns/simple-grid.njk" %}{% enddemo %}
|
Reference in New Issue
Block a user