/ Published in: PHP
URL: http://www.codingforums.com/showthread.php?t=204303
Expand |
Embed | Plain Text
<?php $parts = 6; // dont change, h1 to h6 $base_size = 12; //font-size inherited by parent element, just to see how much pixels the headings will be :) $base_lh = 1.5; //line-height in em $max_size = 300; //maximum font-size in percent (h1) $min_size = 100; //minimum font-size in percent (h6) $percent_per_part = 1 / ($parts -1); $outputstring = 'h%d { margin-bottom:%sem; line-height:%sem; font-size:%s%%; /'.'* %spx *'.'/ }<br>'; $output = ''; for($i=1;$i<$parts+1;$i++) { $y = 1 - (($i - 1) * $percent_per_part); $mult = $percent / 100; $px = $mult * $base_size; $lh = $base_lh / $mult; $output .= sprintf($outputstring, $i, number_format($lh, 3, '.', ''), number_format($lh, 3, '.', ''), $percent, number_format($px, 1, '.', '')); } ?>
You need to login to post a comment.
