homepage Welcome to WebmasterWorld Guest from 54.81.80.46
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Home / Forums Index / Code, Content, and Presentation / Site Graphics and Multimedia Design
Forum Library, Charter, Moderator: open

Site Graphics and Multimedia Design Forum

    
Rotating Image
captainron19




msg:4132925
 8:03 pm on May 14, 2010 (gmt 0)

I have a web page that has a small table to the left of the main content. The background of that area is an image that is defined in the css file.

Is it possible to place a script in there for the image to randomly rotate to a new one with still using the css?

 

thecoalman




msg:4133459
 8:29 am on May 16, 2010 (gmt 0)

You can use php, style.php :


<?php
header("Content-Type: text/css");

$rand_num = mt_rand(1, 4);
?>
.randimage {
background-image: url('randimage<?php echo $rand_num ?>.gif');
}


The first line is the most important because it will send the right header to the browser. The variable $rand_num is assigned a number between 1 to 4.

You'll have four images:
randimage1.gif
randimage2.gif ... etc

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Site Graphics and Multimedia Design
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved