7 replies [Last post]
jfmiller28
Offline
newbie
Sacramento
Last seen: 16 years 20 weeks ago
Sacramento
Timezone: GMT-7
Joined: 2004-07-10
Posts: 3
Points: 0

Greatings All,

I'm working on a site that has a three color scheme. Each of the colors is used in several elements. Unfortunatly, the three colors keep changing as the design is refined. Is there a way to asign a color a name and use it that name instead of #NNNNN?

JFMILLER

FairlyClever
Offline
newbie
Last seen: 16 years 20 weeks ago
Joined: 2004-07-10
Posts: 2
Points: 0

PHP

If you have PHP enabled you can set variables in your stylesheets. I know of some blogging systems that do this. Say you wanted #444444 to be set as darkgrey you could do $darkgrey = '#444444;'; and you could use the syntax like this in the CSS

color: <?php $darkgrey ?>

OR

color: <?php echo $darkgrey; ?>

I THINK! If not let me know.

jfmiller28
Offline
newbie
Sacramento
Last seen: 16 years 20 weeks ago
Sacramento
Timezone: GMT-7
Joined: 2004-07-10
Posts: 3
Points: 0

Managing Colors

looks right to me. Using PHP is stylesheets takes a bit of a hack on my server to get them to return as "text/css." I was hoping that css had this function built in.

mjaz
Offline
newbie
Last seen: 16 years 17 weeks ago
Joined: 2004-08-04
Posts: 3
Points: 0

Managing Colors

How do you make your server accept css as php? I suppose it has something to do with MIME or apache handlers, but I've never messed with those before.

rtm223
rtm223's picture
Offline
Enthusiast
Last seen: 16 years 28 weeks ago
Joined: 2004-05-18
Posts: 58
Points: 0

Managing Colors

<?php
header('Content-type: text/css');
?>

That will send the correct mime type for a css document with a .php extension.

css layout tutorials - in depth layout tutorials for all you newbies D maybe even some stuff for you not-so-new-bies out there P

mjaz
Offline
newbie
Last seen: 16 years 17 weeks ago
Joined: 2004-08-04
Posts: 3
Points: 0

Managing Colors

So if I get it right, I rename my file to style.php, and I put your code at the beginning.
In my html files I put this:
<link rel="stylesheet" type="text/css" href="style.php" />

rtm223
rtm223's picture
Offline
Enthusiast
Last seen: 16 years 28 weeks ago
Joined: 2004-05-18
Posts: 58
Points: 0

Managing Colors

Yep, thats the one. Should work just fine, I actually tried it last week and it was all good. Works on every browser I've tested it on.

css layout tutorials - in depth layout tutorials for all you newbies D maybe even some stuff for you not-so-new-bies out there P

mjaz
Offline
newbie
Last seen: 16 years 17 weeks ago
Joined: 2004-08-04
Posts: 3
Points: 0

Managing Colors

thanks a lot! I'll start making some intelligent css sheets :idea: