I want to manage CSS for a third-party website using PHP. Let's say I want to change the font size of the website, which I will use as input from the user. Can I do it?
You could generate the entire .css file generated by PHP each time, but that lost a bit of the processor. Instead, why not just use the cascading nature of css? Make your PHP output a small piece of CSS on each page to override the font installed in the .css file:
<head> <link rel="stylesheet" href="styles.css" type="text/css"> <style type="text/css"> #some_element { font-size: <?php echo $user_selected_font_size ?>px; } </style> etc...
, .css , , .
css. , 2 CSS , , PHP , . CSS , (, div ..).
CSS file.php:
print " <style type=\"text/css\"> body { color: purple; background-color: {$color} } </style> ";
while $color - , .
$color
- JavaScript " ". jQuery .
( ) CSS PHP ( .php, .css) .
.php
.css
, mystyle.php < link rel= "stylesheet" type = "text/css" href= "[yourdomain]/mystyle.php" >mystyle.php php :
html, body{ font-size: <?php mysql_... ... ?> }
, mod_rewrite .htaccess , 3- mystyle.php mystyle.css( , , , .htaccess)
, css - PHP.
I would recommend that the easiest approach would be to override CSS definitions by manipulating the DOM with Javascript or (even easier!) Including a tag <style>embedded in the page that you are already creating with PHP.
<style>