Files
webawesome/source/docs/grid-system.md
2017-08-09 10:20:46 -04:00

45 lines
1.3 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
layout: default.html
title: Grid System
description: Shoelace doesnt ship with a grid system because you dont need one!
---
## Grid System
Shoelace doesnt ship with a grid system because [you dont 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.
This website uses the CSS Grid Layout. Its really simple!
```html
<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.
```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.