Step 1:
First, rename your CSS file from '.css' to '.css.php'.
style.css
style.css.php
Step 2:
Next, (and this might be obvious), update the link in your HTML file from ...
... to ...
Step 3:
At the top of your CSS document, insert this:
<?php header("Content-type: text/css; charset: UTF-8"); ?>
And now you can put in whatever CSS you want statically, plus insert PHP variables the same as you'd do with HTML.
Static:
body { background-color:rgb(200,230,255); margin:0; padding:0; }
Semi-Static
body { background-color:<?php echo 'rgb(200,230,255)'; ?>; margin:0; padding:0; }
Dynamic
body { background-color:<?php echo bg_color_light; ?>; margin:0; padding:0; }
No comments:
Post a Comment