Created
July 7, 2011 00:22
-
-
Save jakebellacera/1068659 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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