Skip to content

Instantly share code, notes, and snippets.

@joshuamilford
Created August 9, 2012 16:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshuamilford/3305603 to your computer and use it in GitHub Desktop.
Save joshuamilford/3305603 to your computer and use it in GitHub Desktop.
Fluid Grid Maker
<?php
$width = 960;
$columns = 12;
$margin = 10;
$column = ($width / $columns) - (2 * $margin);
echo '<pre>';
$spans = '';
for($i = 1; $i <= 12; $i++)
{
$spans .= '.span_' . $i . ', ';
}
$spans = trim($spans, ', ');
echo $spans . '{
float:left;
margin: 0 ' . (($margin / $width) * 100) . '%;
}';
for($i = 1; $i <= 12; $i++)
{
echo '
.span_' . $i . '{width: ' . ((($i * $column + ((2 * $margin) * ($i - 1))) / $width) * 100). '%;}';
}
echo '</pre>';
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment