1
0
mirror of https://github.com/phuoc-ng/csslayout.git synced 2025-08-30 00:59:47 +02:00

feat: Holy grail

This commit is contained in:
Phuoc Nguyen
2022-09-21 13:02:02 +07:00
parent 92ff05cd4f
commit 3d74fde098
7 changed files with 116 additions and 249 deletions

View File

@@ -0,0 +1,9 @@
<div class="holy-grail">
<div class="holy-grail__header">{% rectangle %}</div>
<div class="holy-grail__main">
<div class="holy-grail__left">{% lines "hor", 4 %}</div>
<div class="holy-grail__middle">{% lines "hor", 10 %}</div>
<div class="holy-grail__right">{% lines "hor", 8 %}</div>
</div>
<div class="holy-grail__footer">{% rectangle %}</div>
</div>

62
contents/holy-grail.md Normal file
View File

@@ -0,0 +1,62 @@
---
layout: layouts/post.njk
title: Holy grail
description: Create a holy grail layout with CSS flexbox
keywords: css flexbox, css holy grail layout, css layout
---
## HTML
```html
<div class="holy-grail">
<header>
...
</header>
<main class="holy-grail__main">
<!-- Left sidebar -->
<aside class="holy-grail__left">...</aside>
<!-- Main content -->
<article class="holy-grail__middle">...</article>
<!-- Right sidebar -->
<nav class="holy-grail__right">...</nav>
</main>
<footer>
...
</footer>
</div>
```
## CSS
```css
.holy-grail {
display: flex;
flex-direction: column;
}
.holy-grail__main {
/* Take the remaining height */
flex-grow: 1;
/* Layout the left sidebar, main content and right sidebar */
display: flex;
flex-direction: row;
}
.holy-grail__left {
width: 25%;
}
.holy-grail__middle {
/* Take the remaining width */
flex-grow: 1;
}
.holy-grail__right {
width: 20%;
}
```
{% demo %}{% include "patterns/holy-grail.njk" %}{% enddemo %}

View File

@@ -110,6 +110,7 @@ eleventyExcludeFromCollections: true
<h2 class="category__name">Layout</h2>
<div class="category__posts">
{% pattern "Card layout" %}{% include "patterns/card-layout.njk" %}{% endpattern %}
{% pattern "Holy grail" %}{% include "patterns/holy-grail.njk" %}{% endpattern %}
</div>
</div>