I have a header.inc and a css style sheet that are called to each page of a website via php. In the style sheet there are two styles that I would like to change depending on the section of the website.
For example:
in the style sheet
css id "subnav" has background: #E8EDF5 and
cssi id "subtitle" has background #E8EDF5
however in each major section of the website I would like to change the background colors of the divs that have id "subnav" and "subtitle".
Is there type of php statement that I could place at the top of my website pages that would allow me to specify the colors of these two css ids?
Hope I have made this clear.
changing css styles with php
Moderator: General Moderators
- Pointybeard
- Forum Commoner
- Posts: 71
- Joined: Wed Sep 03, 2003 7:23 pm
- Location: Brisbane, AUS
- Contact:
What about somthing like this:
Just have some sort of condition there. It looks at the page your on and decides which css file to include.
Code: Select all
<link rel="stylesheet" href="<?= (page your on = major ? 'style1' : 'style2') ?>.css" type="text/css" />Well, the different sections of your site. Do it have different scripts that's running it? For instance section_1.php and section_2.php. If so, you can change the .css files (actually just have one) with a "section_1." in front of all your css entries. Then, in your code you go:
Use this if you've got 2 .css files with the same name classes in each one:
Alternatively... if you have one .css file with the "section_1." in front of each class, you can put the "<?= (basename ($PHP_SELF))?>" in front of each reference to the class (if you're using the CSS in this way). Option 1 above is probably better 
Anyways... good luck
Use this if you've got 2 .css files with the same name classes in each one:
Code: Select all
<link rel="stylesheet" href="<?= (basename ($PHP_SELF) ;?>.css" type="text/css" />Anyways... good luck