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 April 8th, 2004, 05:59 PM
bluetooth20 bluetooth20 is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Location: England
Posts: 45 bluetooth20 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via MSN to bluetooth20
Dynamic CSS Problems

Despite looking through the forum, having problems with dynamically creating an external CSS file. Can any one explain?

Basically I currently have a CSS file:
Code:
.normal
    {
    font-family: Verdana, Arial, Helvetica, sans-serif;

    font-size:   11px;
    }

.userdef
    {
    font-family: Verdana, Arial, Helvetica, sans-serif;

    font-size:   12px;
    color:       #FF0000;
    font-weight: 800;
    }

.big
    {
    font-family: Verdana, Arial, Helvetica, sans-serif;

    font-size:   12px;
    }


I have set the site up so that the user can define there own colour of text for the userdef style, but im unsure how I can put this colour variable into the CSS file. I'm guessing I have to rename it into a .php file... but how will the browser still know its a CSS file??


Thanks very much for your help

Reply With Quote
  #2  
Old April 8th, 2004, 06:27 PM
Clan admin's Avatar
Clan admin Clan admin is offline
AZbb founder
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2004
Location: London, UK
Posts: 843 Clan admin User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 52 m 44 sec
Reputation Power: 5
If it is only ONE element, then it would not be wise to read/write to external files.

- Create your normal CSS, then way you like.
- In the disaply page, import it ie.
<link rel="stylesheet" href="yourcss.css" type="text/css">
- After above entry add a style tag

PHP Code:
<link rel="stylesheet" href="yourcss.css" type="text/css" />
<
style type="text/css">
<!--
<?
php
echo ".userdef    {color: #$user_color; }";
?>
-->
</style>

</head> 


- The above declaration would override the entry in yourcss.css
- Now all you have to do is to feed $user_color ie $user_color = 'FF0000'; or get it from $_POST.


This is a quick guide. You have to work on it. Make sure you have a default value and do not pass blank to $user_color


Good luck



ps. Better still:

PHP Code:
if (isset($color))
$user_color ".userdef    {color: #$color; }"; }
else {
$user_color "";}

## inside the styles:
echo $user_color;
<
style type="text/css">
<!--
<?
php echo $user_color?>
-->
</style> 


All you have to do is to get $color
__________________
© AZ

AZbb :: AZ Bulletin Board - Secure BBS script, Front page CMS, Chat, No database
Simple Guide to Apache and PHP installation on Windows

Last edited by Clan admin : April 8th, 2004 at 06:32 PM. Reason: Added code

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > Dynamic CSS Problems


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