Posted By


brettbergeron on 09/08/09

Tagged


Statistics


Viewed 704 times
Favorited by 1 user(s)

CSS Grid Generator


/ Published in: PHP
Save to your folder(s)

Code explains itself. I plan to do a lot more work on it - just wanted to throw it up here for a little sharing. Feel free to take it to the next level.


Copy this code and paste it in your HTML
  1. <?php
  2.  
  3. header("Content-type: text/css");
  4.  
  5. $columns = 4;
  6. $column_size = 215;
  7. $column_gutter = 20;
  8. $rule = array('border-top' => '2px solid black', 'margin-top' => '10px');
  9.  
  10. $sizes = array('one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen');
  11.  
  12. for($n = 1; $n <= $columns; $n++)
  13. {
  14. echo $sizes[$n - 1] ." { ";
  15.  
  16. echo "width: " . ($column_size * $n + $column_gutter * ($n - 1) ) . "px; ";
  17.  
  18. foreach($rule as $property => $value):
  19.  
  20. echo "$property: $value; ";
  21.  
  22. endforeach;
  23.  
  24. echo "} \n";
  25. }
  26.  
  27.  
  28.  
  29. /* End of file grid.php */

URL: http://brettbergeron.com

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.