Darkfly Posted September 11, 2009 Share Posted September 11, 2009 Hey all, I'm having some problems with PHP. I've been googling for while now looking for some answers, but can't quite fine what I'm looking for. Here's whats up. I have a PHP file, that is as follows: // sets the default color for the user text $def_fontColor = "#000000"; //<--- Sets colour black, hard coded. Want to try and have this load from the CSS file instead. This is a config file, which loads other php files. What I'm trying to do is I'm setting up web themes with the CSS file, and its workign great. I have the other pages loading the difference themes when a user picks it, but the default font colour is black on all of them cause the config file for the PHP as above is hard coded it. What I would like to do is instead of it hard coded in, have it call the CSS file, and use the colours in there. Example CSS: // sets the default color for the user text .def_fontColor { color: #EDF1FA; } Does anyone know how I can do that? Quote Link to comment https://forums.phpfreaks.com/topic/173933-solved-php-and-css/ Share on other sites More sharing options...
p2grace Posted September 11, 2009 Share Posted September 11, 2009 Why would you need php at all for this type of functionality? Couldn't this be accomplished by strictly using css? Quote Link to comment https://forums.phpfreaks.com/topic/173933-solved-php-and-css/#findComment-916890 Share on other sites More sharing options...
Darkfly Posted September 11, 2009 Author Share Posted September 11, 2009 Everything does use the CSS, however in this one PHP config file, its coding a colour that all users that type or post, will be black, and this doesn't work so well if lets say the background colour is coded black in the CSS file. Quote Link to comment https://forums.phpfreaks.com/topic/173933-solved-php-and-css/#findComment-916898 Share on other sites More sharing options...
Darkfly Posted September 11, 2009 Author Share Posted September 11, 2009 Anyone else have any ideas to this problem of mine? Quote Link to comment https://forums.phpfreaks.com/topic/173933-solved-php-and-css/#findComment-916917 Share on other sites More sharing options...
peranha Posted September 11, 2009 Share Posted September 11, 2009 Not quite sure if this is what you are after, but in the <head> section of your page you will need a link to the css file. <head> <link href="style.css" rel="stylesheet" type="text/css" /> </head> Then on your pages you will call that depending on whether you set it to an "id" or a "class". Quote Link to comment https://forums.phpfreaks.com/topic/173933-solved-php-and-css/#findComment-916919 Share on other sites More sharing options...
Darkfly Posted September 11, 2009 Author Share Posted September 11, 2009 Okay, that didn't work out quite so well, but anyways I found where the background colour was being called from in the config.php Over here in this file template.main.php <?php include("config.php"); <div id="message_border" name="message_border" class="message_border" style="right:<?php echo $style_right;?>px;bottom: <?php echo $style_bottom;?>px;position:fixed;background: url('backgrounds/<?php echo $_SESSION['room_image'];?>') center center no-repeat;background-color: <?php echo $background_color;?>;"/> <div id="div_chat" class="message_display" style="z-index:99;bottom: <?php echo $style_bottom;?>px;"> <font class="username"><?php echo html_entity_decode($_SESSION['room_desc']);?></font> </div> </div> ?> Where it's saiys background-color: <?php echo $background_color;?> you can see thats where if gets the colour from the config.php So I present a new problem. I want to have that defined in the CSS file now, not in the config.php. How would I go about this? Quote Link to comment https://forums.phpfreaks.com/topic/173933-solved-php-and-css/#findComment-916961 Share on other sites More sharing options...
sticks464 Posted September 12, 2009 Share Posted September 12, 2009 Why can't you delete this so no call is made background-color: <?php echo $background_color;?>; and add a background color for either the id or class div id="message_border" name="message_border" class="message_border" #message_border { background-color:#fff; } Quote Link to comment https://forums.phpfreaks.com/topic/173933-solved-php-and-css/#findComment-917075 Share on other sites More sharing options...
Darkfly Posted September 12, 2009 Author Share Posted September 12, 2009 Hmm, thats what I though too. But doesn't seem to work. Like when I remove that, it keeps the background transparent (cause its table onto of the page) Anyways I found a work around that seems to have work. Thanks a buch guys for your help. Quote Link to comment https://forums.phpfreaks.com/topic/173933-solved-php-and-css/#findComment-917393 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.