Jump to content

[SOLVED] dynamic stylesheets


prime

Recommended Posts

Just a simple question I've tested this in a browser and it works.

 

I know you can set the content-type using the header funtion for example

 

header("Content-Type: text/css");

 

Does this mean that you can use php to generate a css stylesheet for example

 

instead of having a file names style.css you have it named styles.php that contains

 

<?php
header("Content-Type: text/css");
?>

 

at the top of the file

 

for example here is the start if a test file I have created

 

<?php
header("Content-Type: text/css");
?>
body {

   height: 100%;
   color: black;

}

div#topmenu
{
	background: #000066;
	position: absolute;
	position: fixed;
	top: 0px;
	left: 13%;
	width: 87%;
	height: 13%;
	text-align: center;
	z-index: 3;
}

/*styles continue but not needed for this example */

 

If this is valid, This means you can dynamicaly generate css content, am I right in thinking this. Or is there a problem I'm not realising.

 

If I'm right this could solve a lot of probems I've been having.

 

Is this valid? would it work across all browsers?

Link to comment
https://forums.phpfreaks.com/topic/73582-solved-dynamic-stylesheets/
Share on other sites

If this is valid it would allow the power of php to be applied to stylesheets.

 

I'm just asking if it's valid before I go changing everything ove ron my sites, as this would allow a lot of flexibility being able to do variables and if's in styesheets.

 

but I'm hoping for an answer from someone more experienced first if this is valid

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.