TECH Need CSS tips for my personal site.

dmora

How do i make HTML load random CSS options?
Like if i wanted to change the color of the outlines and <h#>'s etc.
 

owt200x

New Member
Nov 2, 2008
6
Name your stylesheets in some order, say style1.css, style2.css etc.
Add this to your php loading code at the top of your page, the 1,5 is how many css files you have, start at 1 end at 5.

<? $num = rand(1,5); ?>


then put this after your head but before your body code

<link rel="stylesheet" type="text/css" href="css/style<? echo $num; ?>.css">
 

White Stormy

Take that, subspace!
Sep 17, 2002
85,544
Sparkopolis
make one stylesheet as a base, and just write some javascript to change the colors using random numbers

no reason to add php processing for something dumb like that
 

owt200x

New Member
Nov 2, 2008
6
its alot easier using what i posted above than using javascript, which can be disabled by the ones looking at your site, php cant be disabled
 

White Stormy

Take that, subspace!
Sep 17, 2002
85,544
Sparkopolis
its alot easier using what i posted above than using javascript, which can be disabled by the ones looking at your site, php cant be disabled

but is the overhead of the extra php processing really worth such a trivial gain?

I guess if you're more concerned with bandwidth than cpu usage, go the PHP route.
 

owt200x

New Member
Nov 2, 2008
6
actually the code to do this in php is a lot smaller and less complicated than javascript, and i dont know JS

plus with php and css you can make sure different color schemes dont conflict with each other, using random colors with javascript, you may get a pile of poo for colors, instead of certain schemes.
 
Last edited:

White Stormy

Take that, subspace!
Sep 17, 2002
85,544
Sparkopolis
actually the code to do this in php is a lot smaller and less complicated than javascript, and i dont know JS

plus with php and css you can make sure different color schemes dont conflict with each other, using random colors with javascript, you may get a pile of poo for colors, instead of certain schemes.

random numbers to randomly pick a stylesheet :uh:

http://www.alistapart.com/articles/alternate/
 

owt200x

New Member
Nov 2, 2008
6
not trying to argue with u, just saying using the php code i put above is alot easier than javascript
 

deusexaethera

OT Supporter
Jan 27, 2005
18,592
but is the overhead of the extra php processing really worth such a trivial gain?

I guess if you're more concerned with bandwidth than cpu usage, go the PHP route.
The PHP is all executed on the server; all it will do is choose a CSS sheet when the client requests to see the page, and then the page and the chosen CSS file will get sent out to the client.
 

White Stormy

Take that, subspace!
Sep 17, 2002
85,544
Sparkopolis
The PHP is all executed on the server; all it will do is choose a CSS sheet when the client requests to see the page, and then the page and the chosen CSS file will get sent out to the client.

yeah..

just seems wasteful to me to use php to alter presentation when js is perfectly capable

either will work, though.
 

Users who are viewing this thread

About Us

  • Please do not post anything that violates any Local, State, Federal or International Laws. Your privacy is protected. You have the right to be forgotten. Site funded by advertising, link monetization and member support.
OT v15.8.1 Copyright © 2000-2022 Offtopic.com
Served by fu.offtopic.com

Online statistics

Members online
333
Guests online
50
Total visitors
383

Forum statistics

Threads
369,774
Messages
16,919,358
Members
86,876
Latest member
ddunn9448