Forums
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Hi all
How to make Dynamic CSS, and import it to my php page ??
Thanx in advance.
Pardon? What about the CSS do you want to be dynamic?
Are you talking about media queries for multiple devices such as iPhones and Androids?
Thanx for replay
I need to make PHP inside CSS
You can’t do that. Be specific in what you’re trying to do.
look in JQuery in can with this code
AddType application/x-httpd-php .js
so i thought i can make same thin for css
Aah, with .htaccess
Yes, it’s possible to do this. You must save you’re css file as .php and echo some PHP in this .css.php file. At the top (no space before it) you place the following code:
Now the browser use this file as an css file, but php things work. Withing the page you can load it:
thanx all
WouterJ Thanx , but not working Look to the code below :
this is an index.php page
HI
and this is a style.css.php page :
body{
background: ;
}
Could you please correct the code if any mistake !
the style.css.php page needs to have the content-type header – not your index.php! It’s the stylesheet that needs to be served as text/css.
wow amazing thanx alot it’s working!
hi, thanks in advance
how can i include this .css.php file
You’d link to it in the <head> section of your web page, just like any other stylesheet. The only difference is that it would have the .php extension;
<link rel="stylesheet" href="/path/to/stylesheet.php" />
it does n’t work for me
stylesheet.php;
<?php
header("Content-type: text/css");
$bg_color = '#ff0000';
?>
html { background:<?php echo $bg_color;?> }
Web page header;
<link rel="stylesheet" href="/path/to/stylesheet.php" />