Permalink
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Grd - A CSS grid framework using Flexbox</title> | |
<link rel="stylesheet" href="https://cdn.jsdelivr.net/highlight.js/9.2.0/styles/github.min.css"> | |
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,700"> | |
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto Mono:400,700"> | |
<link rel="stylesheet" href="dist/grd.css"> | |
<style> | |
html { | |
font-family: "Roboto", sans-serif; | |
} | |
h1 > img { | |
width: 100%; | |
max-width: 480px; | |
} | |
code { | |
color: #333; | |
background: #f8f8f8; | |
font-family: "Roboto Mono", monospace; | |
} | |
.container { | |
margin: auto; | |
max-width: 960px; | |
} | |
.Grid { | |
margin: 1rem; | |
padding: 1rem; | |
min-height: 200px; | |
border: 1px solid #ccc; | |
} | |
.Grid > .Cell { | |
padding: 1rem; | |
border: 1px dashed #ccc; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="container"> | |
<h1><img src="logo.png" alt="Grd"></h1> | |
<p>A CSS grid framework using Flexbox.</p> | |
<ul> | |
<li><strong>Simple</strong>: Provides just 2 base classes <code>Grid</code> and <code>Cell</code> and some modifiers.</li> | |
<li><strong>Light-weight</strong>: <u>Only 512 bytes</u> (Gzipped).</li> | |
<li><strong>Flexible</strong>: Easy to use Flexbox features.</li> | |
</ul> | |
<p><a href="http://caniuse.com/#search=flex">Flexible Box Layout Module</a> and <a href="http://caniuse.com/#search=calc"><code>calc()</code> as CSS unit value</a> used in Grd are available on modern browsers (Chrome, Firefox, Safari, Opera, Edge and IE11).</p> | |
<h2>Installation</h2> | |
<pre><code class="bash"># via npm | |
$ npm install grd | |
# via bower | |
$ bower install grd</code></pre> | |
<h2>Usage</h2> | |
<pre><code class="html"><div class="Grid"> | |
<div class="Cell -3of12">3of12</div> | |
<div class="Cell -9of12">9of12</div> | |
</div></code></pre> | |
<h2>Live Demo</h2> | |
<div> | |
<button id="add" class="btn" type="button">Add item</button> | |
<button id="remove" class="btn" type="button">Remove item</button> | |
<select id="align-items"> | |
<option value="" selected>-</option> | |
<option value="-top">-top</option> | |
<option value="-middle">-middle</option> | |
<option value="-bottom">-bottom</option> | |
<option value="-stretch">-stretch</option> | |
<option value="-baseline">-baseline</option> | |
</select> | |
<select id="justify-content"> | |
<option value="" selected>-</option> | |
<option value="-left">-left</option> | |
<option value="-center">-center</option> | |
<option value="-right">-right</option> | |
<option value="-between">-between</option> | |
<option value="-around">-around</option> | |
</select> | |
</div> | |
<div class="Grid" id="grid"></div> | |
<template id="template-cell"> | |
<div class="Cell" contenteditable> | |
<select class="select-sm"> | |
<option value="" selected>-</option> | |
<option value="-fill">-fill</option> | |
<option value="-1of12">-1of12</option> | |
<option value="-2of12">-2of12</option> | |
<option value="-3of12">-3of12</option> | |
<option value="-4of12">-4of12</option> | |
<option value="-5of12">-5of12</option> | |
<option value="-6of12">-6of12</option> | |
<option value="-7of12">-7of12</option> | |
<option value="-8of12">-8of12</option> | |
<option value="-9of12">-9of12</option> | |
<option value="-10of12">-10of12</option> | |
<option value="-11of12">-11of12</option> | |
<option value="-12of12">-12of12</option> | |
</select> | |
</div> | |
</template> | |
</div> | |
<a href="https://github.com/1000ch/grd" class="github-corner"><svg width="80" height="80" viewbox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style> | |
<script> | |
document.addEventListener('DOMContentLoaded', function() { | |
var grid = document.querySelector('#grid'); | |
var align = document.querySelector('#align-items'); | |
var justify = document.querySelector('#justify-content'); | |
function onGridChange() { | |
grid.className = `Grid ${align.value} ${justify.value}`; | |
} | |
align.addEventListener('change', onGridChange); | |
justify.addEventListener('change', onGridChange); | |
var template = document.querySelector('#template-cell'); | |
var add = document.querySelector('#add'); | |
var remove = document.querySelector('#remove'); | |
add.addEventListener('click', function() { | |
var cell = document.importNode(template.content, true); | |
var select = cell.querySelector('select'); | |
grid.appendChild(cell); | |
select.addEventListener('change', function() { | |
select.parentNode.className = `Cell ${select.value}`; | |
}); | |
}); | |
remove.addEventListener('click', function() { | |
if (grid.children.length) { | |
grid.children[grid.children.length - 1].remove(); | |
} | |
}); | |
add.click(); | |
add.click(); | |
}); | |
</script> | |
<script src="https://cdn.jsdelivr.net/highlight.js/9.2.0/highlight.min.js"></script> | |
<script>hljs.initHighlightingOnLoad();</script> | |
</body> | |
</html> |