Changing the values in a css

This is a discussion on Changing the values in a css within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Suppose I am creating a web page from within php. The web page will utilize a style sheet. However, before ...


Go Back   Usenet Forums > PHP Programming Forums > alt.comp.lang.php

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-16-2003
Ike
 
Posts: n/a
Default Changing the values in a css

Suppose I am creating a web page from within php. The web page will utilize
a style sheet. However, before I spawn this new page, I want to be able to
change the values in the css, from, within say a javascript function in the
page that will call the php-created page.

How might I do this? Suppose I have the following css:
.td1 {
font: bold 10pt Helvetica;
background: white;
}
.td2 {
font: bold 10pt Helvetica;
background: grey;
}
.trhead {
font: bold 11pt Helvetica;
background: white;
}And I wish to change, say, the font and background values for
the three divisions. Is anyone aware of a class for changing a css on the
fly? Thanks, Ike


Reply With Quote
  #2 (permalink)  
Old 12-16-2003
 
Posts: n/a
Default Re: Changing the values in a css


"Ike" <rxv@hotmail.com> wrote in message
news:mXIDb.1435$Ts5.235@newsread2.news.atl.earthli nk.net...
> Suppose I am creating a web page from within php. The web page will

utilize
> a style sheet. However, before I spawn this new page, I want to be able to
> change the values in the css, from, within say a javascript function in

the
> page that will call the php-created page.
>
> How might I do this? Suppose I have the following css:
> .td1 {
> font: bold 10pt Helvetica;
> background: white;
> }
> .td2 {
> font: bold 10pt Helvetica;
> background: grey;
> }
> .trhead {
> font: bold 11pt Helvetica;
> background: white;
> }And I wish to change, say, the font and background values for
> the three divisions. Is anyone aware of a class for changing a css on the
> fly? Thanks, Ike
>
>



It would be easy enough to do with the style sheet in the php page. $size
could come from a _GET or SESSION or anything.
I supposed you could also modify this to include external style sheets as
well.

# somephpfile.php

<?
$size = 12;
?>

<head>
<style>
..td1 {
font-size: <?=$size?> pt;
}
</style>
</head>
<body>
........

##

you could also call a javascript function with <body
onLoad="javascript:someFunction()">
that changes the values.





Reply With Quote
  #3 (permalink)  
Old 12-16-2003
Jedi121
 
Posts: n/a
Default Re: Changing the values in a css

"Ike" a écrit le 16/12/2003 :
> Suppose I am creating a web page from within php. The web page will utilize
> a style sheet. However, before I spawn this new page, I want to be able to
> change the values in the css, from, within say a javascript function in the
> page that will call the php-created page.
>
> How might I do this? Suppose I have the following css:
> .td1 {
> font: bold 10pt Helvetica;
> background: white;
> }
> .td2 {
> font: bold 10pt Helvetica;
> background: grey;
> }
> .trhead {
> font: bold 11pt Helvetica;
> background: white;
> }And I wish to change, say, the font and background values for
> the three divisions. Is anyone aware of a class for changing a css on the
> fly? Thanks, Ike


Generate the CSS file with PHP.
That's the way I do it : take data in DB from user (colors) then create
the CSS.
Actually the link to the CSS file in my HTML is a PHP script.

--
Have you read the manual ?
http://www.php.net/manual/en/

Reply With Quote
  #4 (permalink)  
Old 12-17-2003
Ike
 
Posts: n/a
Default Re: Changing the values in a css


>
> Generate the CSS file with PHP.


How? I thought I could only generate an html file with php. Dou you mean,
say, with file x.css, write x.php, instead of just having the css text, I
might have php code, and then in my generated html file (generated by php),
which uses x.css, I have it use x.php ? -Ike


Reply With Quote
  #5 (permalink)  
Old 12-17-2003
Jedi121
 
Posts: n/a
Default Re: Changing the values in a css

"Ike" a écrit le 17/12/2003 :
>>
>> Generate the CSS file with PHP.

>
> How? I thought I could only generate an html file with php. Dou you mean,
> say, with file x.css, write x.php, instead of just having the css text, I
> might have php code, and then in my generated html file (generated by php),
> which uses x.css, I have it use x.php ? -Ike


You can generate any file you want, even CSS or JPG or whatever.
Yes you can simply link in your HTML page a php script :

<LINK REL='stylesheet' TYPE="text/css" HREF='styles.php'>

An exmaple of this styles.php file could be :
(don't forget to put sources for the values of the vars like reading
them from DB or cookie or session...)

<STYLE TYPE="text/css">
<!--
BODY
{
background-color: #<?echo(light($coul_fond,"20"))?>;
background-attachment: fixed;
scrollbar-face-color: #<?echo($coul_cadre)?>;
scrollbar-highlight-color: #<?echo(light($coul_cadre,"20"))?>;
scrollbar-shadow-color: #<?echo(dark($coul_cadre,"20"))?>;
scrollbar-3dlight-color: #<?echo(light($coul_fond,"20"))?>;
scrollbar-arrow-color: #<?echo(light($coul_fond,"20"))?>;
scrollbar-track-color: #<?echo($coul_fond)?>;
scrollbar-darkshadow-color: #<?echo(dark($coul_cadre,"60"))?>;
}
-->
</STYLE>

--
Have you read the manual ?
http://www.php.net/manual/en/

Reply With Quote
  #6 (permalink)  
Old 12-30-2003
Rob
 
Posts: n/a
Default Re: Changing the values in a css


"Ike" <rxv@hotmail.com> schreef in bericht
news:8jPDb.1110$wL6.208@newsread1.news.atl.earthli nk.net...
>
> >
> > Generate the CSS file with PHP.

>
> How? I thought I could only generate an html file with php. Dou you mean,
> say, with file x.css, write x.php, instead of just having the css text, I
> might have php code, and then in my generated html file (generated by

php),
> which uses x.css, I have it use x.php ? -Ike
>
>


yes
examples

<script type="text/javascript" src="javascript.php"/>

<link type="text/css" href="style.php" relation="stylesheet"/>

<img src="image.php"/>

the php extension will tell apache to let the php module handle the page.
the tags will tell the browser how to handle the (generated) data

Rob




Reply With Quote
  #7 (permalink)  
Old 12-30-2003
CountScubula
 
Posts: n/a
Default Re: Changing the values in a css

> > > Generate the CSS file with PHP.
> >
> > How? I thought I could only generate an html file with php. Dou you

mean,
> > say, with file x.css, write x.php, instead of just having the css text,

I
> > might have php code, and then in my generated html file (generated by

> php),
> > which uses x.css, I have it use x.php ? -Ike



If you do this, and you want the contents of the css will change often or
depeding on the page, make sure you send some headers to tell the browser
not to cache the file.

I generaly use a rather large .css file, and one the browser loads it, it
will cache it and not load it again, (for a little while that is) this make
the page load faster vs. having style tags in every page that can get
lenghtly

--
Mike Bradley
http://gzen.myhq.info -- free online php tools


Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:38 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0