CSS random image

Talk about HTML resources, styles etc.
Post Reply
Posts: 15
Joined: Sat Feb 28, 2004 10:19 pm
Location: Georgia, USA

CSS random image

Post by UberM » Wed Feb 02, 2005 6:26 pm

Does anyone know of a way to use pure CSS to have a rotating or random image?
For example: Each time you come to a page it has a different image. I know this can be done with JS, PHP and others but I'm trying to do this with CSS only. I have looked online and no one seems to have a "yes" or "no" answer. Anyone have any ideas or suggestions?

User avatar
Site Admin
Posts: 2256
Joined: Sun Oct 05, 2003 9:09 pm

Post by rchmura » Thu Feb 03, 2005 12:59 pm

Based on how I've used CSS and my understanding is "no". CSS is designed to be a method of defining presentation "without moving parts" Generally you will need javascript or cgi to rotate an image.

If anyone else knows otherwise please let me know ;)

Posts: 15
Joined: Sat Feb 28, 2004 10:19 pm
Location: Georgia, USA

Post by UberM » Thu Feb 03, 2005 7:18 pm

That's what I thought. I have seen some code for attempts at getting it to work but the "logic" they used didn't work out. Oh well...
Thanks Rich for the help!

web counter beginner
Posts: 1
Joined: Thu Apr 28, 2005 6:52 am

Post by 0riginal » Thu Apr 28, 2005 7:01 am

It is possible to make and with help CSS, somewhere I saw it, it is necessary to recollect.

bean counter
Posts: 73
Joined: Tue Nov 04, 2003 6:44 pm
Location: Britain

Post by scrag » Thu Apr 28, 2005 12:49 pm

I don't know whether this is possible. You would have to assign a class to your <img> tag to get it to randomise somehow. It's a nice thought to be able to do something like that with CSS though :)
We don't own the world, we borrow it from our children.
The Weird World of Us

five fingers
Posts: 5
Joined: Thu Jun 14, 2007 8:58 am

Post by exipnos » Wed Jul 04, 2007 8:38 am

you can use this :

#header {
background-image: url(image.jpg);

and it is now:

background-image: url(headers/rotate.php);

where in rotate.php you can load a random image

Post Reply