Carbon Grid was inspired by some of the most popular grid systems, but built to be lightweight and simple to use. In other words, for less than 5kb (unzipped) you get a CSS grid system that can handle almost any layout and takes about 5 minutes to learn.
Intro: Carbon Grid uses flexbox which is awesome and can do a lot, but this system is designed to only address the most common layout issues. If you need very specific flex features it's very easy to expand on the base styles. Flexbox is a relatively new addition to CSS, so make sure you check the browser support before using. It's been tested back to IE 9 and seems to work well.
Download:
https://raw.githubusercontent.com/Stegosource/carbon-grid/master/dist/css/carbon-grid.css
NPM:
npm install carbon-grid --save
Bower:
bower install carbon-grid --save
CDN:
<link rel="stylesheet" href="https://unpkg.com/carbon-grid/dist/css/carbon-grid.css">
Wraps content to a consistent width. It's not necessary to use the container, but your wrapper should have padding left and right of 15px.
<div class="container">
<span class="example-content"></span>
</div>
Example:
Wraps content to for full width of sections.
<div class="container-fluid">
<span class="example-content"></span>
</div>
Example:
Rows and columns create responsive flexbox grids. Because it is built on flexbox (which is awesome), column widths adjust automatically.
<div class="container">
<div class="row">
<div class="column">
<span class="example-content"></span>
</div>
<div class="column">
<span class="example-content"></span>
</div>
<div class="column">
<span class="example-content"></span>
</div>
</div>
</div>
Example:
Example (2 columns):
Example (4 columns):
Set explicit widths for more control over column width at various breakpoints.
Naming conventions are as follows: {breakpoint}-{width}
Name | Width | in pixels |
---|---|---|
xs | 0 - 36rem | 0 - 576px |
sm | > 36rem | > 576px |
md | > 48rem | > 768px |
lg | > 62rem | > 992px |
xl | > 75rem | > 1200px |
Supported Widths:
<div class="container">
<div class="row">
<div class="column sm-50 lg-25">
<span class="example-content"></span>
</div>
<div class="column sm-50 lg-25">
<span class="example-content"></span>
</div>
<div class="column sm-50 lg-25">
<span class="example-content"></span>
</div>
<div class="column sm-50 lg-25">
<span class="example-content"></span>
</div>
</div>
</div>
Example: Grid with 4 columns on large screens, 2 columns on middle screens, and 1 on smallest
Remove spacing around containers and columns.
<div class="container fill">
<div class="row">
<div class="column">
<span class="example-content"></span>
</div>
<div class="column">
<span class="example-content alt-color"></span>
</div>
</div>
</div>
Example (container):
Example (container-fluid):
Reverse the order of columns in a row. Supports breakpoints.
<div class="container">
<div class="row sm-reverse">
<div class="column">
<span class="example-content"></span>
</div>
<div class="column">
<span class="example-content alt-color"></span>
</div>
</div>
<div class="row">
<div class="column">
<span class="example-content"></span>
</div>
<div class="column">
<span class="example-content alt-color"></span>
</div>
</div>
</div>
Example: On smallest screens alt-color is second, but the order is reversed on the first row after the first breakpoint.
By default, the row justifies content to the left. But it's possible to center content or justify to the right.
<div class="container">
<div class="row justify-center">
<div class="column sm-50">
<span class="example-content"></span>
</div>
</div>
<div class="row justify-right">
<div class="column sm-50">
<span class="example-content"></span>
</div>
</div>
</div>
Example: