CSS sheet in PHP?
Moderator: General Moderators
CSS sheet in PHP?
whats the code to link a CSS style sheet to php?
Last edited by xEzMikex on Sun Feb 05, 2006 3:21 pm, edited 1 time in total.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
its not actually php, php could output this though
or
is the "php way"
Code: Select all
<link rel="stylesheet" href="/template/style.css" type="text/css">Code: Select all
echo '<link rel="stylesheet" href="/template/style.css" type="text/css">';-
highonsnow
- Forum Newbie
- Posts: 5
- Joined: Sat Feb 04, 2006 1:59 pm
You could also shave off a little overhead by avoiding the echo and simply doing this:
Since PHP has no business with that string, why send it through the parser
Code: Select all
?><link rel="stylesheet" href="/template/style.css" type="text/css"><?- raghavan20
- DevNet Resident
- Posts: 1451
- Joined: Sat Jun 11, 2005 6:57 am
- Location: London, UK
- Contact:
jcart would have demonstrated the power of the PHP to use dynamic CSS dependent on conditions...highonsnow wrote:You could also shave off a little overhead by avoiding the echo and simply doing this:
Since PHP has no business with that string, why send it through the parserCode: Select all
?><link rel="stylesheet" href="/template/style.css" type="text/css"><?
-
highonsnow
- Forum Newbie
- Posts: 5
- Joined: Sat Feb 04, 2006 1:59 pm
I'm sure he didn't ask for that ability but with a little creativity you could simply:
Can't be too fussy 
Code: Select all
?><link rel="stylesheet" href="/template/<?echo $vars_template_name;?>/style.css" type="text/css"><?- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
If you wanted your stylesheet to be dynamic you can also try this:
... and the somescript.php file...
Code: Select all
<link rel="stylesheet" type="text/css" href="somescript.php?page=prices" />Code: Select all
<?php header('Content-type: text/css'); ?>
body {
margin: 0;
padding: 5px 20px;
background-color: <?php
switch ($_GET['page'])
{
case 'prices' :
echo '#EEEEEE;';
break;
default:
echo '#FFFFFF;';
}
?>
}
div#foo {
border: 1px dotted #AAAAAA;
}
/* etc etc etc */allright well one more problem... its not reading....
this is the element im using.
this is my style sheet code
and this is my directory setup
Code: Select all
<link rel="stylesheet" href="/skin/ice_blue/index.css" type="text/css">Code: Select all
body{
margin-top:5px;
background-image:url(images/bg.gif);
}
div.banner{
background-image:url(images/1_01.gif);
color:#000000;
margin:auto;
height:100px;
width:700px;
top:0px;
}
div.links{
background-image:url(images/1_02.gif);
color:#000000;
margin:auto;
height:14px;
width:700px;
font-size: 9px;
font-family: Verdana, Arial, Helvetica, sans-serif;
text-align: center;
}
div.content{
background-image:url(images/1_03.gif);
color:#000000;
margin:auto;
height:auto;
width:700px;
font-size: 9px;
font-family: Verdana, Arial, Helvetica, sans-serif;
text-indent:2px;
}
div.end{
background-image:url(images/1_04.gif);
color:#000000;
margin:auto;
height:2px;
width:700px;
}Code: Select all
|ROOT|
index.php
|SKIN|
|IMAGES|
index.css- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
sorry for the bump... uhm the images folder is in the ice_blue folder so i thought i only had to put "/images/<img>" he css file is being imported its just not the pitures i think.d11wtq wrote:The images don't look like they've been referenced correctly.... is the entire CSS file not being imported or is it just the images?
href="/skin/ice_blue/index.css"
background-image:url(../images/bg.gif);
EDIT i fixed it.. the element wasnt in the right place thanks for the help.