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 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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 |
|
|||
|
"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. |
|
|||
|
"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/ |
|
|||
|
> > 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 |
|
|||
|
"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/ |
|
|||
|
"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 |
|
|||
|
> > > 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 |