Hi List, good Monday to you.
Is there a way I can give a DIV a random background color? From a list
of pre-defined colors?
Can't find anything suitable on Google.
thanks,
Paul
__
css-discuss [EMAIL PROTECTED]
On 27/02/06, Paul Annett [EMAIL PROTECTED] wrote:
Is there a way I can give a DIV a random background color? From a list
of pre-defined colors?
Not with CSS. You could modify the CSS or markup (class name for
example) on the fly with Javascript or server side programming.
--
David Dorward
Hi Paul !
Some javascript should do the trick
script
//Enter list of bgcolors:
var bgcolorlist=new Array(#afafaf, #1f1f1f, #80ff80, #eafeaf,
#f7f7f7, #f8f8f8, #ff, #dd)
yourrandombackgroundcolordiv.bgColor=bgcolorlist[Math.floor(Math.random()*bg
colorlist.length)]
/script
Jens Peter
At 04:01 AM 2/27/2006, Paul Annett wrote:
Is there a way I can give a DIV a random background color? From a list
of pre-defined colors?
Ya cain't get thar from here. CSS can't do it.
OT: Random number generation is built in to today' scripting
languages, e.g. in PHP rand(0,255) generates a
anyone who wants - off the board i can send some php code or a mysql
query to generate random numbers or pull random colors / hex codes from
a list or database, day of the week, other (friday = green). i use
random functions for changing output in galleries, business spotlights,
etc. if you