CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 11th, 2004, 06:24 AM
jarow jarow is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 83 jarow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
changing css styles with php

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.

Reply With Quote
  #2  
Old March 11th, 2004, 06:33 AM
JohanL's Avatar
JohanL JohanL is offline
Updated
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Location: Sweden
Posts: 124 JohanL User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Short answer: No.
Long answer: Yes, but you'll have to create a script that output the css based on the page calling it. Another way is to create diferent style sheets for every section. Or you could place the statements subnav and subtitle in a <style> in the page you create and not in the style sheet...

Reply With Quote
  #3  
Old March 11th, 2004, 06:37 AM
Kimppa Kimppa is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2001
Location: Finland
Posts: 711 Kimppa User rank is Sergeant Major (2000 - 5000 Reputation Level)Kimppa User rank is Sergeant Major (2000 - 5000 Reputation Level)Kimppa User rank is Sergeant Major (2000 - 5000 Reputation Level)Kimppa User rank is Sergeant Major (2000 - 5000 Reputation Level)Kimppa User rank is Sergeant Major (2000 - 5000 Reputation Level)Kimppa User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 5 Days 19 h 19 m 54 sec
Reputation Power: 35
PHP Code:
<?php
if(<-- statement -->) {
 
$bgcolor1 "#FF0000";
}
else 
 
$bgcolor1 "#E8EDF5";
?>

<head>
   <style>
.subnav{
background-color: <?php print $bgcolor1?>;
}
  </style>
</head>


If that's not ok, then you could make several CSS files and include the one with correct colors

PHP Code:
<?php
if(<-- statement -->)
print 
"<link rel=\"stylesheet\" type=\"text/css\" href=\"style1.css\">";

else 
print 
"<link rel=\"stylesheet\" type=\"text/css\" href=\"style_default.css\">";
?>
__________________
Fatal error on row 561: Couldn't access life - life isn't set

Reply With Quote
  #4  
Old March 12th, 2004, 11:26 AM
tvc3mye's Avatar
tvc3mye tvc3mye is online now
Daniel Schildsky
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2004
Location: KL, Malaysia.
Posts: 629 tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level)tvc3mye User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 6 Days 7 h 57 m 21 sec
Reputation Power: 201
Send a message via ICQ to tvc3mye Send a message via MSN to tvc3mye Send a message via Yahoo to tvc3mye
Quote:
Originally Posted by jarow
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.


besides using Kimppa's method, u can also try 2 override the div tag style using style attribute....
set the style attributes with the desired colour using php script...

Last edited by tvc3mye : March 12th, 2004 at 11:29 AM. Reason: correction....

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > changing css styles with php


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT