|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
are variables possible in CSS?
I want to build a style switcher for my site, to allow users to change color schemes, font sizes, etc. But I hate duplicating data, and having all those style sheets that are basically identical except for the color styles worries me. Is there some way that I could set the colors to variables (ie, $dark, $medium, $light) and then use the variables to define the styles? That way I could stay with just one style sheet.
Any ideas? Thanks, Daniel |
|
#2
|
||||
|
||||
|
What are you using to change the styles when a user selects a different one?
__________________
# Jeremy Explain your problem instead of asking how to do what you decided was the solution. |
|
#3
|
|||
|
|||
|
JSP (& PHP)
For the site I'm working on now, I use JSP, but most of my sites are built with PHP and I'd like to do it both ways. Current configuration is that the site has a default stylesheet. If the user selects a different one, a variable in their session is added. Each page checks the session and, depending on the presence & content of the variable, returns the appropriate stylesheet to use for that page.
|
|
#4
|
||||
|
||||
|
One option is to make multiple stylesheets: one for the global styles that don't change (like <div> locations and sizes), and one for each style option with the styles that do change (like colors). Then when you build your page, <link> to the global stylesheets and whichever color stylesheet has been choosen.
Another option is to build one stylesheet that contains PHP variables and replace those variables when you build the page. The eval() function will be helpfull here. |
![]() |
| Viewing: Dev Shed Forums > Web Design > CSS Help > are variables possible in CSS? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|