Skip to content

Instantly share code, notes, and snippets.

@prestontimmons
Created February 9, 2012 18:16
Show Gist options
  • Save prestontimmons/1781740 to your computer and use it in GitHub Desktop.
Save prestontimmons/1781740 to your computer and use it in GitHub Desktop.
generate css grid in Python
""" Usage: python grid.py > grid.css """
MAX = 960
COL = 10
rules = []
rules.append(".column { float: left; min-height: 1px; }")
for x in range(COL, MAX + COL, COL):
rules.append(".column-%s { width: %spx; }" % (x, x))
for x in range(COL, (MAX + COL) / 2, COL):
rules.append(".column-push-%s { margin-left: %spx; }" % (x, x))
for x in range(COL, (MAX + COL) / 2, COL):
rules.append(".column-pull-%s { margin-left: -%spx; }" % (x, x))
for x in rules:
print x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment