Skip to content

Instantly share code, notes, and snippets.

@jamesfoster
Created July 2, 2010 10:43
Show Gist options
  • Save jamesfoster/461203 to your computer and use it in GitHub Desktop.
Save jamesfoster/461203 to your computer and use it in GitHub Desktop.
/* --------------------------------------------------------------
grid-css.less
* Sets up an easy-to-use grid of 24 columns.
By default, the grid is 950px wide, with 24 columns
spanning 30px, and a 10px margin between columns.
If you need fewer or more columns, namespaces or semantic
element names, use the compressor script (lib/compress.rb)
-------------------------------------------------------------- */
@import "grid";
/* A container should group all your columns. */
.container {
#blueprint > .container();
}
/* Use this class on any .span / container to see the grid. */
.showgrid {
#blueprint > .showgrid();
}
/* Columns
-------------------------------------------------------------- */
/* Sets up basic grid floating and margin. */
.column, .span-1, .span-2, .span-3, .span-4, .span-5, .span-6, .span-7, .span-8, .span-9, .span-10, .span-11, .span-12, .span-13, .span-14, .span-15, .span-16, .span-17, .span-18, .span-19, .span-20, .span-21, .span-22, .span-23, .span-24 {
#blueprint > .column();
}
/* The last column in a row needs this class. */
.last { #blueprint > .last(); }
/* Use these classes to set the width of a column. */
.span-1 { #blueprint > .span(1); }
.span-2 { #blueprint > .span(2); }
.span-3 { #blueprint > .span(3); }
.span-4 { #blueprint > .span(4); }
.span-5 { #blueprint > .span(5); }
.span-6 { #blueprint > .span(6); }
.span-7 { #blueprint > .span(7); }
.span-8 { #blueprint > .span(8); }
.span-9 { #blueprint > .span(9); }
.span-10 { #blueprint > .span(10); }
.span-11 { #blueprint > .span(11); }
.span-12 { #blueprint > .span(12); }
.span-13 { #blueprint > .span(13); }
.span-14 { #blueprint > .span(14); }
.span-15 { #blueprint > .span(15); }
.span-16 { #blueprint > .span(16); }
.span-17 { #blueprint > .span(17); }
.span-18 { #blueprint > .span(18); }
.span-19 { #blueprint > .span(19); }
.span-20 { #blueprint > .span(20); }
.span-21 { #blueprint > .span(21); }
.span-22 { #blueprint > .span(22); }
.span-23 { #blueprint > .span(23); }
.span-24 { #blueprint > .span(24); }
/* Use these classes to set the width of an input. */
input.span-1, textarea.span-1, input.span-2, textarea.span-2, input.span-3, textarea.span-3, input.span-4, textarea.span-4, input.span-5, textarea.span-5, input.span-6, textarea.span-6, input.span-7, textarea.span-7, input.span-8, textarea.span-8, input.span-9, textarea.span-9, input.span-10, textarea.span-10, input.span-11, textarea.span-11, input.span-12, textarea.span-12, input.span-13, textarea.span-13, input.span-14, textarea.span-14, input.span-15, textarea.span-15, input.span-16, textarea.span-16, input.span-17, textarea.span-17, input.span-18, textarea.span-18, input.span-19, textarea.span-19, input.span-20, textarea.span-20, input.span-21, textarea.span-21, input.span-22, textarea.span-22, input.span-23, textarea.span-23, input.span-24, textarea.span-24 {
#blueprint > .input-span()
}
input.span-1, textarea.span-1 { #blueprint > .input-span(1); }
input.span-2, textarea.span-2 { #blueprint > .input-span(2); }
input.span-3, textarea.span-3 { #blueprint > .input-span(3); }
input.span-4, textarea.span-4 { #blueprint > .input-span(4); }
input.span-5, textarea.span-5 { #blueprint > .input-span(5); }
input.span-6, textarea.span-6 { #blueprint > .input-span(6); }
input.span-7, textarea.span-7 { #blueprint > .input-span(7); }
input.span-8, textarea.span-8 { #blueprint > .input-span(8); }
input.span-9, textarea.span-9 { #blueprint > .input-span(9); }
input.span-10, textarea.span-10 { #blueprint > .input-span(10); }
input.span-11, textarea.span-11 { #blueprint > .input-span(11); }
input.span-12, textarea.span-12 { #blueprint > .input-span(12); }
input.span-13, textarea.span-13 { #blueprint > .input-span(13); }
input.span-14, textarea.span-14 { #blueprint > .input-span(14); }
input.span-15, textarea.span-15 { #blueprint > .input-span(15); }
input.span-16, textarea.span-16 { #blueprint > .input-span(16); }
input.span-17, textarea.span-17 { #blueprint > .input-span(17); }
input.span-18, textarea.span-18 { #blueprint > .input-span(18); }
input.span-19, textarea.span-19 { #blueprint > .input-span(19); }
input.span-20, textarea.span-20 { #blueprint > .input-span(20); }
input.span-21, textarea.span-21 { #blueprint > .input-span(21); }
input.span-22, textarea.span-22 { #blueprint > .input-span(22); }
input.span-23, textarea.span-23 { #blueprint > .input-span(23); }
input.span-24, textarea.span-24 { #blueprint > .input-span(24); }
/* Add these to a column to append empty cols. */
.append-1 { #blueprint > .append(1); }
.append-2 { #blueprint > .append(2); }
.append-3 { #blueprint > .append(3); }
.append-4 { #blueprint > .append(4); }
.append-5 { #blueprint > .append(5); }
.append-6 { #blueprint > .append(6); }
.append-7 { #blueprint > .append(7); }
.append-8 { #blueprint > .append(8); }
.append-9 { #blueprint > .append(9); }
.append-10 { #blueprint > .append(10); }
.append-11 { #blueprint > .append(11); }
.append-12 { #blueprint > .append(12); }
.append-13 { #blueprint > .append(13); }
.append-14 { #blueprint > .append(14); }
.append-15 { #blueprint > .append(15); }
.append-16 { #blueprint > .append(16); }
.append-17 { #blueprint > .append(17); }
.append-18 { #blueprint > .append(18); }
.append-19 { #blueprint > .append(19); }
.append-20 { #blueprint > .append(20); }
.append-21 { #blueprint > .append(21); }
.append-22 { #blueprint > .append(22); }
.append-23 { #blueprint > .append(23); }
/* Add these to a column to prepend empty cols. */
.prepend-1 { #blueprint > .prepend(1); }
.prepend-2 { #blueprint > .prepend(2); }
.prepend-3 { #blueprint > .prepend(3); }
.prepend-4 { #blueprint > .prepend(4); }
.prepend-5 { #blueprint > .prepend(5); }
.prepend-6 { #blueprint > .prepend(6); }
.prepend-7 { #blueprint > .prepend(7); }
.prepend-8 { #blueprint > .prepend(8); }
.prepend-9 { #blueprint > .prepend(9); }
.prepend-10 { #blueprint > .prepend(10); }
.prepend-11 { #blueprint > .prepend(11); }
.prepend-12 { #blueprint > .prepend(12); }
.prepend-13 { #blueprint > .prepend(13); }
.prepend-14 { #blueprint > .prepend(14); }
.prepend-15 { #blueprint > .prepend(15); }
.prepend-16 { #blueprint > .prepend(16); }
.prepend-17 { #blueprint > .prepend(17); }
.prepend-18 { #blueprint > .prepend(18); }
.prepend-19 { #blueprint > .prepend(19); }
.prepend-20 { #blueprint > .prepend(20); }
.prepend-21 { #blueprint > .prepend(21); }
.prepend-22 { #blueprint > .prepend(22); }
.prepend-23 { #blueprint > .prepend(23); }
/* Border on right hand side of a column. */
.border { #blueprint > .border(); }
/* Border with more whitespace, spans one column. */
.colborder { #blueprint > .colborder(); }
/* Use these classes on an element to push it into the
next column, or to pull it into the previous column. */
.pull-1 { #blueprint > .pull(1); }
.pull-2 { #blueprint > .pull(2); }
.pull-3 { #blueprint > .pull(3); }
.pull-4 { #blueprint > .pull(4); }
.pull-5 { #blueprint > .pull(5); }
.pull-6 { #blueprint > .pull(6); }
.pull-7 { #blueprint > .pull(7); }
.pull-8 { #blueprint > .pull(8); }
.pull-9 { #blueprint > .pull(9); }
.pull-10 { #blueprint > .pull(10); }
.pull-11 { #blueprint > .pull(11); }
.pull-12 { #blueprint > .pull(12); }
.pull-13 { #blueprint > .pull(13); }
.pull-14 { #blueprint > .pull(14); }
.pull-15 { #blueprint > .pull(15); }
.pull-16 { #blueprint > .pull(16); }
.pull-17 { #blueprint > .pull(17); }
.pull-18 { #blueprint > .pull(18); }
.pull-19 { #blueprint > .pull(19); }
.pull-20 { #blueprint > .pull(20); }
.pull-21 { #blueprint > .pull(21); }
.pull-22 { #blueprint > .pull(22); }
.pull-23 { #blueprint > .pull(23); }
.pull-24 { #blueprint > .pull(24); }
.pull-1, .pull-2, .pull-3, .pull-4, .pull-5, .pull-6, .pull-7, .pull-8, .pull-9, .pull-10, .pull-11, .pull-12, .pull-13, .pull-14, .pull-15, .pull-16, .pull-17, .pull-18, .pull-19, .pull-20, .pull-21, .pull-22, .pull-23, .pull-24 { #blueprint > .pull(); }
.push-1 { #blueprint > .push(1); }
.push-2 { #blueprint > .push(2); }
.push-3 { #blueprint > .push(3); }
.push-4 { #blueprint > .push(4); }
.push-5 { #blueprint > .push(5); }
.push-6 { #blueprint > .push(6); }
.push-7 { #blueprint > .push(7); }
.push-8 { #blueprint > .push(8); }
.push-9 { #blueprint > .push(9); }
.push-10 { #blueprint > .push(10); }
.push-11 { #blueprint > .push(11); }
.push-12 { #blueprint > .push(12); }
.push-13 { #blueprint > .push(13); }
.push-14 { #blueprint > .push(14); }
.push-15 { #blueprint > .push(15); }
.push-16 { #blueprint > .push(16); }
.push-17 { #blueprint > .push(17); }
.push-18 { #blueprint > .push(18); }
.push-19 { #blueprint > .push(19); }
.push-20 { #blueprint > .push(20); }
.push-21 { #blueprint > .push(21); }
.push-22 { #blueprint > .push(22); }
.push-23 { #blueprint > .push(23); }
.push-24 { #blueprint > .push(24); }
.push-1, .push-2, .push-3, .push-4, .push-5, .push-6, .push-7, .push-8, .push-9, .push-10, .push-11, .push-12, .push-13, .push-14, .push-15, .push-16, .push-17, .push-18, .push-19, .push-20, .push-21, .push-22, .push-23, .push-24 { #blueprint > .push(); }
/* Misc classes and elements
-------------------------------------------------------------- */
/* In case you need to add a gutter above/below an element */
.prepend-top {
#blueprint > .prepend-top();
}
.append-bottom {
#blueprint > .append-bottom();
}
/* Use a .box to create a padded box inside a column. */
.box {
#blueprint > .box();
}
/* Use this to create a horizontal ruler across a column. */
hr {
#blueprint > .hr();
}
hr.space {
#blueprint > .hr-space();
}
/* Clearing floats without extra markup
Based on How To Clear Floats Without Structural Markup by PiE
[http://www.positioniseverything.net/easyclearing.html] */
.clearfix, .container { #blueprint > .clearfix(); }
/* Regular clearing
apply to column that should drop below previous ones. */
.clear { #blueprint > .clear(); }
// --------------------------------------------------------------
//
// grid.less
// * Sets up an easy-to-use grid of 24 columns.
//
// By default, the grid is 950px wide, with 24 columns
// spanning 30px, and a 10px margin between columns.
//
// If you need fewer or more columns, namespaces or semantic
// element names, use the compressor script (lib/compress.rb)
//
// --------------------------------------------------------------
@width: 950px;
@margin: 10px;
@column-width: (@width + @margin) / 24;
@input-padding: 5px;
@input-border: 1px;
#blueprint {
// A container should group all your columns.
.container() {
width: @width;
margin: 0 auto;
}
// Use this class on any .span / container to see the grid.
.showgrid() {
background: url(src/grid.png);
}
// Columns
// --------------------------------------------------------------
// Sets up basic grid floating and margin.
.column() {
float: left;
margin-right: @margin;
}
.span() { #blueprint > .column(); }
// The last column in a row needs this class.
.last() { margin-right: 0; }
// Use these classes to set the width of a column.
.span(@column) { width: @column-width * @column - @margin;}
.span(24) { margin-right: 0; }
// Use these classes to set the width of an input.
.input-span() {
border-left-width: @input-border;
border-right-width: @input-border;
padding-left: @input-padding;
padding-right: @input-padding;
}
.input-span(@column) { width: @column-width * @column - @margin - 2 * @input-border - 2 * @input-padding; }
// Add these to a column to append empty cols.
.append(@column) { padding-right: @column-width * @column;}
// Add these to a column to prepend empty cols.
.prepend(@column) { padding-left: @column-width * @column;}
// Border on right hand side of a column.
.border() {
padding-right: 4px;
margin-right: 5px;
border-right: 1px solid #eee;
}
// Border with more whitespace, spans one column.
.colborder() {
padding-right: 24px;
margin-right: 25px;
border-right: 1px solid #eee;
}
// Use these classes on an element to push it into the
// next column, or to pull it into the previous column.
.pull(@column) { margin-left: -1 * @column-width * @column; }
.pull() {float: left; position:relative;}
.push(@column) { margin: 0 (-1 * @column-width * @column) 1.5em (@column-width * @column); }
.push() {float: right; position:relative;}
// Misc classes and elements
// --------------------------------------------------------------
// In case you need to add a gutter above/below an element
.prepend-top() {
margin-top:1.5em;
}
.append-bottom() {
margin-bottom:1.5em;
}
// Use a .box to create a padded box inside a column.
.box() {
padding: 1.5em;
margin-bottom: 1.5em;
background: #E5ECF9;
}
// Use this to create a horizontal ruler across a column.
.hr() {
background: #ddd;
color: #ddd;
clear: both;
float: none;
width: 100%;
height: .1em;
margin: 0 0 1.45em;
border: none;
}
.hr-space() {
background: #fff;
color: #fff;
visibility: hidden;
}
// Clearing floats without extra markup
// Based on How To Clear Floats Without Structural Markup by PiE
// [http://www.positioniseverything.net/easyclearing.html]
.clearfix() {
display: block;
&:after {
content: "\0020";
display: block;
height: 0;
clear: both;
visibility: hidden;
overflow:hidden;
}
}
// Regular clearing
// apply to column that should drop below previous ones.
.clear() { clear: both; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment