grid.min v0.0.3
Grid.min
A minimum and lightweight responsive grid CSS library.
Table of Contents
Installation
npm:
npm install --save grid.min
(https://www.npmjs.com/package/grid.min)Sample CDN:
<link rel="stylesheet" type="text/css" href="https://rawgit.com/paulocheque/grid.min/master/dist/grid.min.css">
About the Library
- grid.css ~4.3kb
- grid.min.css ~3.1kb
- grid.min.css.gz ~650bytes
- No typographic css or other stuff.
Motivation
Most of the CSS frameworks and libraries define many CSS classes and include some default design in the library. Eventually, the frontend developer will have to override these CSS classes for customisation which generates many bad practices. Another option is to compile the framework with your design variables, with is not a straightforward solution.
For that reason, grid.min does not include any default design at all and provides only a few CSS classes that will help to create responsive grids. It also does not include any component into the library, since this library has only one responsibility: provide an easy way to create responsive grids.
Documentation
The library is so simple that all the documentation is below.
Live example
JSFiddle: https://jsfiddle.net/n54ru51z/1/
The Grid
- Grid of 12 columns
- Default configured media queries: 360, 480, 640, 768, 1024 and 1200 px.
- Border-sizing: border-box
- Columns have the same height
- Margins, paddings and borders are 0 by default.
- Recommendation to use normalize.css.
CSS Classes
.grid
, .col
, .c-*
, .c-360-*
, .c-480-*
, .c-640-*
, .c-768-*
, .c-1024-*
, .c-1200-*
*
means 1 to 12
Sample Code
<!DOCTYPE html>
<html>
<head>
<!-- Required -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Recommended -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css" integrity="sha256-t2/7smZfgrST4FS1DT0bs/KotCM74XlcqZN5Vu7xlrw=" crossorigin="anonymous" />
<!-- Required -->
<link rel="stylesheet" type="text/css" href="./grid.css">
</head>
<body>
<div class="grid">
<div class="col c-12 c-360-12 c-480-6 c-640-4 c-768-3 c-1024-2 c-1200-1">cell 1</div>
<div class="col c-12 c-360-12 c-480-6 c-640-4 c-768-3 c-1024-2 c-1200-1">cell 2</div>
<div class="col c-12 c-360-12 c-480-6 c-640-4 c-768-3 c-1024-2 c-1200-1">cell 3</div>
<div class="col c-12 c-360-12 c-480-6 c-640-4 c-768-3 c-1024-2 c-1200-1">cell 4</div>
<div class="col c-12 c-360-12 c-480-6 c-640-4 c-768-3 c-1024-2 c-1200-1">cell 5</div>
<div class="col c-12 c-360-12 c-480-6 c-640-4 c-768-3 c-1024-2 c-1200-1">cell 6</div>
<div class="col c-12 c-360-12 c-480-6 c-640-4 c-768-3 c-1024-2 c-1200-1">cell 7</div>
<div class="col c-12 c-360-12 c-480-6 c-640-4 c-768-3 c-1024-2 c-1200-1">cell 8</div>
<div class="col c-12 c-360-12 c-480-6 c-640-4 c-768-3 c-1024-2 c-1200-1">cell 9</div>
<div class="col c-12 c-360-12 c-480-6 c-640-4 c-768-3 c-1024-2 c-1200-1">cell 10</div>
<div class="col c-12 c-360-12 c-480-6 c-640-4 c-768-3 c-1024-2 c-1200-1">cell 11</div>
<div class="col c-12 c-360-12 c-480-6 c-640-4 c-768-3 c-1024-2 c-1200-1">cell 12</div>
</div>
</body>
</html>
Supported Browsers
OS / Browser | Chrome | Firefox | Safari | Opera | MS Edge | MS IE 11 |
---|---|---|---|---|---|---|
Mac | Supported | Supported | Supported1 | Supported | N/A | N/A |
Linux | Supported | Supported | ? | Supported | N/A | N/A |
Windows | Supported | ? | ? | ? | Supported | Supported |
Android | ? | ? | ? | ? | N/A | N/A |
iOS | ? | ? | Supported1 | ? | N/A | N/A |
- Safari has some issues with border-box and display: table when stacking horizontally.