Skip to content

Instantly share code, notes, and snippets.

@jakebellacera
Created July 7, 2011 00:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jakebellacera/1068659 to your computer and use it in GitHub Desktop.
Save jakebellacera/1068659 to your computer and use it in GitHub Desktop.
w = container width
s = spacing
n = amount of columns
=====
CSS
=====
.columns {
width: w; /* Width is purely optional. Static, non-floating block elements default at 100% */
overflow: hidden; /* We have floating child elements, we need to keep them inside -- hide the doors. Damn kids. */
}
/**
* Define spacing
* ==============
* Typically you want to have 20px for spacing, s = 20px
**/
.columns > div { margin: 0 s 0 0; }
.columns > .last { margin: 0; } /* The "last" column needs to have its margin killed */
/**
* Define widths
* =============
* For four columns, n = 4.
* For three columns, n = 3.
**/
.columns.four > div { width: (w - s(n - 1))/n); }
======
HTML
======
div.columns.four
div
div
div
div.last
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment