Thread: CSS & Variables

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Posts
    13
    Rep Power
    0

    CSS & Variables


    I'm doing a site, but I'm trying to make it as modular as possible, so that when someone buys it I can change everything on the site in a very short time. I'm using CSS because its fantastic, and it makes my life a lot easier. My question is:

    Can I define a variable in the HTML of a site and have the CSS objects on the page behave differently as a result. For example:

    If I put in the variable, say:

    <%pagecolour%="FF0000">

    Can I then have the CSS in my style.css sheet say something like:
    Code:
    a:visited{
    	color: %pagecolour%;
    	text-decoration: none;
    	border-bottom: 1px dotted #6699CC;
    }
    and have it fill in the colour on-the-fly.

    It would mean that I can change the colours of the colour coded parts of the site (the text, table borders, etc.) in one easy step, and that'd be fantastic!

    Thanks in advance for any help.
  2. #2
  3. nx
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2003
    Location
    USA
    Posts
    626
    Rep Power
    0
    umm...if you have access to server-side languages maybe..
  4. #3
  5. King of RGB
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Location
    brussels
    Posts
    398
    Rep Power
    11
    mmmmmmh... a ruin for webdesigners and for surprising websites. but the question itself is challenging...
    as such, no, you cannot. But you could create an executable file (a software, really) "template generator" that would ask you to fill in all the values for the variables like the "pagecolour" one, and then generate the pages and the CSS stylesheets on the fly on your desktop. This system, correlated to a database, containing the content.
    and then upload the template where you want.

    but really, dreamweaver MX is a good tool for those wanting to use templates and dynamic content.
    http://www.pixeline.be
    ........................................
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2003
    Posts
    112
    Rep Power
    11
    I don't know if this helps you but somewhere on thsi forum I read about how to make different stylesheets for a website so you copy the stylesheet blue.css rename it to green.css and the only thing you change inside is the main color from blue to green. Then you only have to find a way to let the visitor choose which css file to use.

    I know there are ways to do that, but seems like it is very browser dependant. just search dev shed I know I read it somewhere here.
  8. #5
  9. nx
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2003
    Location
    USA
    Posts
    626
    Rep Power
    0
    theres also a very complex way to do it using javascript that i use on my sites and all you do is just give color values to your variables, add the actual css code generation functions below, and then youre done.
    if ya want it, i can have it for ya

    [[[terminal]]]

IMN logo majestic logo threadwatch logo seochat tools logo