Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

text style changer

Status
Not open for further replies.

dfelstead

MIS
Feb 7, 2006
7
GB
Hi

I'm designing/building a site and want the titles for the site to change fonts, styles etc each time it loads.

The title will be html text and I ideally I wanted the text to say have a number variations such as a choice between fonts, a choice between styles (underlined, strikethrough, bold, italic etc) and possibly sizes as well. Each time the page loads the script selected one from each of these attributes so every time the titles will be different, sometime it will be in Times, underlined and at 36pt and another time it will be Arial, bold and 24pt.

If anyone can help with this I would be most grateful.

Cheers
 
I would create 2 arrays, that would hold the valid font types, and the valid decorations(bold, underline etc..) and then just randomize them.


sort of like:

Code:
$fonts[0]="Arial";
$fonts[1]="Times New Roman";
$Fonts[2]="Courier";

$decorations[0]="bold";
$decorations[1]="underline";
$decorations[2]="overline";

and then for the sizes just 
$font=$fonts[rand(0,3)];
$decorate=$decorations[rand(0,3)];
$size=rand(10,24);

Then just add those to the style definition of yur title like:

.main {
	font-family: <?echo $font;?>;
	font-size: <?echo $size; ?>;
	font-style: <?echo $decorate;?>;

}

?It will run everytime the page is loaded and randomize the attributes and output them directly into the CSS style block.

[red]Note you have to have this within the PHP page, and have the style block for the title there too, as the server will not parse any PHP in CSS files.[red]

----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top