How to call a function from CSS
Posted: Wed Oct 22, 2008 6:02 am
I added AddType application/x-httpd-php .css to my .htaccess file and I wrote the following php code (in a file called rhythm.php):
And now I am stuck (I am rather new at this). How do I call this "function" from within my CSS-file?
Code: Select all
<?php
$FontSize = $_GET['fontsize']; // Font size of current element in px
$BaseLineHeight = $_GET['lineheight']; // line height in px
$MarginTop = $_GET['margint']; // top margin in multiples of line height
$MarginBotom = $_GET['marginb']; // bottom margin in multiples of line height
$BorderTop = $_GET['bordert']; // top border in px
$BorderBottom = $_GET['borderb']; //bottom border in px
$NewLineHeight = $BaseLineHeight / $FontSize;
$PixelBase = 1 / $FontSize;
$BorderTop = $BorderTop * $PixelBase;
$BorderBottom = $BorderBottom * $PixelBase;
$MarginTop = ($MarginTop * $NewLineHeight) - $BorderTop;
$MarginBottom = ($MarginTop * $NewLineHeight) - $BorderBottom;
if {$NewLineHeight < 1) {
$NewLineHeight = $NewLineHeight * 2;
}
echo "line-height: $NewLineHeight;
margin-top: $MarginTop;
margin-bottom: $MarginBottom;
border-bottom-width: $BorderBottom;
border-top-width: $BorderTop;"
?>