From aae80da887ac8ec5aea6051b9a291e6f86bf227c Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Wed, 9 Aug 2017 10:20:46 -0400 Subject: [PATCH] Add CSS grid example --- docs/grid-system.html | 26 +++++++++++++++++++++++++- source/docs/grid-system.md | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 2 deletions(-) diff --git a/docs/grid-system.html b/docs/grid-system.html index cbc9e3c15..a051c34f6 100644 --- a/docs/grid-system.html +++ b/docs/grid-system.html @@ -48,7 +48,31 @@

Grid System

Shoelace doesn’t ship with a grid system because you don’t need one. You should use the CSS Grid Layout instead.

-

If you have an obligation to support older browsers, consider using the Bootstrap grid without any extras in combination with Shoelace.

+

This website uses the CSS Grid Layout. It’s really simple!

+
<main id="wrap">
+  <nav id="nav">
+    ...
+  </nav>
+
+  <div id="content">
+    ...
+  </div>
+</main>
+
+

Now we just need a couple styles to turn the nav and content elements into columns. This will make the nav 12rem wide and the content 100% - 12rem so it fills the rest of the space.

+
#wrap {
+  display: grid;
+  grid-template-columns: 12rem calc(100% - 12rem);
+}
+
+

You can use media queries to make grids responsive. This is how we make the nav appear on top of the content on smaller screens.

+
@media (max-width: 60rem) {
+  #wrap {
+    display: block;
+  }
+}
+
+

Support for CSS Grid Layouts is very good, but if you have an obligation to support older browsers, consider using the Bootstrap grid without any extras in combination with Shoelace.

diff --git a/source/docs/grid-system.md b/source/docs/grid-system.md index 115cd3691..459671a3f 100644 --- a/source/docs/grid-system.md +++ b/source/docs/grid-system.md @@ -8,4 +8,37 @@ description: Shoelace doesn’t ship with a grid system because you don’t need Shoelace doesn’t ship with a grid system because [you don’t need one](https://rachelandrew.co.uk/archives/2017/07/01/you-do-not-need-a-css-grid-based-grid-system/). You should use the [CSS Grid Layout](https://gridbyexample.com/) instead. -If you have an obligation to support older browsers, consider using the Bootstrap grid [without any extras](https://github.com/zirafa/bootstrap-grid-only) in combination with Shoelace. +This website uses the CSS Grid Layout. It’s really simple! + +```html +
+ + +
+ ... +
+
+``` + +Now we just need a couple styles to turn the nav and content elements into columns. This will make the nav `12rem` wide and the content `100% - 12rem` so it fills the rest of the space. + +```css +#wrap { + display: grid; + grid-template-columns: 12rem calc(100% - 12rem); +} +``` + +You can use media queries to make grids responsive. This is how we make the nav appear on top of the content on smaller screens. + +```css +@media (max-width: 60rem) { + #wrap { + display: block; + } +} +``` + +Support for CSS Grid Layouts is [very good](http://caniuse.com/css-grid), but if you have an obligation to support older browsers, consider using the Bootstrap grid [without any extras](https://github.com/zirafa/bootstrap-grid-only) in combination with Shoelace.