Topic: Loading a Random BG using CSS (Page 1 of 1) Pages that link to <a href="" title="Pages that link to Topic: Loading a Random BG using CSS (Page 1 of 1)" rel="nofollow" >Topic: Loading a Random BG using CSS <span class="small">(Page 1 of 1)</span>\

Radical Rob
Bipolar (III) Inmate

From: Lost Angeles Kalifornia, via Hawaii....
Insane since: Jun 2001

IP logged posted posted 02-04-2007 18:24 Edit Quote

Is there a way to do this? I want to have about 10 images and I'd like the BG to be random. I know I can do it if it was a regular img, .... i dunno, practical?

Lunatic (VI) Inmate

From: under the bed
Insane since: Feb 2000

IP logged posted posted 02-04-2007 18:33 Edit Quote

Through CSS alone, no.

I would do this by setting several classes in your stylesheet which define different background images, and use whatever method you prefer to randomly declare the class for that element in your markup.

Paranoid (IV) Inmate

From: Norway
Insane since: Jun 2002

IP logged posted posted 02-04-2007 19:36 Edit Quote

For the cross fading banner(s) on my site, I wrote a PHP script that returns a random image in its folder. I can use it directly as the src attribute of an IMG tag or as the background-image property of a CSS rule.

To make the whole thing look a bit cleaner from the outside, I named the PHP script random.jpg and use an .htaccess to make sure it's processed as PHP.

Maniac (V) Mad Librarian

From: the space between us
Insane since: Sep 2002

IP logged posted posted 02-04-2007 23:49 Edit Quote

i did pretty much what poi mentioned here by using the sig rotator script. i asked for permission of course

The Space Between Us | My Blog:

Post Reply
Your User Name:
Your Password:
Login Options: Remember Me On This Computer
Your Text:
Options: Show Signature
Enable Slimies
Enable Linkwords

« BackwardsOnwards »

Show Forum Drop Down Menu