Forum Moderators: not2easy

Message Too Old, No Replies

New Images Upon Refresh

         

Steverino

5:42 pm on Apr 12, 2005 (gmt 0)

10+ Year Member



Im coding a home page and wish to have a new image (an array of 10) appear upon refresh.

How can I do this using .css?

Thanks!

nwhorton

5:46 pm on Apr 12, 2005 (gmt 0)

10+ Year Member



Well one thing you can do which is easy but not at all efficient is to have a bunch of .css files (one for each of the different images) and rotate them using an ASP or PHP script.

I'm trying to do something similar (see this thread: [webmasterworld.com...] by setting up a script to rotate the images from within the .css file. It's not very easy...at least I can't seem to get it working, but it seems to be the most effecient way to do it.

MWpro

1:33 am on Apr 13, 2005 (gmt 0)

10+ Year Member



You cannot do this with purely css.

You would need a scripting language, like javascript, php, etc. To do it with php, I would just name all the images like "image1.gif", "image2.gif", etc, and when the page loads, use php to get a random number between 1 and 10, assign that random number to a variable such as $random, and then echo out something like this:

echo "<img src=\"image$random.gif\" alt=\"\" />";