essence is a minimalist layout engine powered by less mixins. It provides powerful percentage-based responsive grid functionality without the need for ugly non-semantic classes (e.g. col3 or span-8).
install
Bower is recommended for front-end package management:
bower install essence --save
Or you can download the latest version manually from GitHub.
But really, you should just use Bower.
use
A basic layout with a main section and a sidebar.
#container {
// start a layout
.essence();
> section {
// main content is 75% of the page
.cell( (3/4) );
}
> aside {
// set up a sidebar to be 25% width
.cell( (1/4) );
}
}Result:
3/4You can also use percentages instead of fractions.
.cell(100%) or .cell() creates a full-width cell.
#container {
.essence();
> header {
// full-width cell
.cell();
}
> section:nth-child(even) {
.cell(30%);
}
> section:nth-child(odd) {
.cell(70%);
}
}Result:
.cell() = 100%30%70%Advanced options include offsets, custom gutter sizes and alternative breakpoints.
// you can set global defaults...
@default-gutter: 3%;
@default-breakpoint: 960px;
// ...or do it per layout:
#container {
// set a custom gutter and breakpoint
.essence(@gutter: 1%; @breakpoint: 1024px);
> div {
// cells will stack below 1024px
.cell( (1/6); @gutter: 1%; @breakpoint: 1024px );
&:nth-child(3) {
// offset by 1/3
.offset( (1/3); @gutter: 1%; @breakpoint: 1024px );
}
}
}Result:
1/61/61/61/6For the ultimate responsive setup, use media queries to change layouts at different sizes.
#container {
.essence();
> div {
.cell( (1/2) );
@media (min-width: 1024px) {
.cell( (1/3) );
}
@media (min-width: 1200px) {
.cell( (1/4) );
}
}
}Result:
extend
Fork the essence repo and make essence work for you... then open an issue to get your fork featured here!