Posted By

brettbergeron on 09/08/09


Tagged

css php


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

WinterCrow
AzizLight


CSS Grid Generator


 / Published in: PHP
 

URL: http://brettbergeron.com

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.

  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 */

Report this snippet  

You need to login to post a comment.