Digital Point Forums
Wire Transfer

Go Back   Digital Point Forums > Design & Development > HTML & Website Design > CSS
Google Analytics
Log In to view
your analytics

Reply
 
Thread Tools
  #1  
Old Aug 25th 2006, 2:29 am
SLM-why's Avatar
SLM-why SLM-why is offline
Twilight Vanquisher
 
Join Date: Aug 2006
Location: India
Posts: 879
SLM-why is on a distinguished road
Post Random Background image, preload image using css

1) Is it possible to preload image using css? If yes, how?
Here is the format of my css....

Code:
body {
background-image: url(g9brk05.gif);
margin-left: 5px;
margin-top: 5px;
margin-right: 5px;
margin-bottom: 2px;
}
2) Is it possible to use random background image using css?........... How?
Reply With Quote
  #2  
Old Aug 25th 2006, 8:47 pm
ccoonen's Avatar
ccoonen ccoonen is offline
of the Nightfall
 
Join Date: Jun 2006
Location: Earth
Posts: 1,485
ccoonen is just really niceccoonen is just really niceccoonen is just really niceccoonen is just really nice
Red face

preloading: javascript can pre-load images. Just pre-load the img you are using in your CSS background.

Random bg Image:
you need to use some sort of css/altering language as in javascript or a server-side language. you could inline it and say:

html4strict Code:
<div id="bgImg" style="background:url(/images/thiscanberandomized.gif) no-repeat top left;">aaaaaaa</div>
to randomize it with php you would do

html4strict Code:
<div id="bgImg" style="background:url(/images/<?= "img_".rand(0,1000).".gif"; ?>) no-repeat top left;">aaaaaaa</div>
create 1000 images in your images folder called /img_1.gif, /img_2.gif etc..
__________________
Find Cheap Furniture # Appleton Wisconsin Plumber - Paul J. Coonen Plumbing
Reply With Quote
  #3  
Old Aug 26th 2006, 3:16 am
supriyadisw's Avatar
supriyadisw supriyadisw is offline
Champion of the Naaru
 
Join Date: Aug 2006
Location: Jakarta
Posts: 196
supriyadisw is on a distinguished road
Quote:
Originally Posted by ccoonen View Post
preloading: javascript can pre-load images. Just pre-load the img you are using in your CSS background.

Random bg Image:
you need to use some sort of css/altering language as in javascript or a server-side language. you could inline it and say:

html4strict Code:
<div id="bgImg" style="background:url(/images/thiscanberandomized.gif) no-repeat top left;">aaaaaaa</div>
to randomize it with php you would do

html4strict Code:
<div id="bgImg" style="background:url(/images/<?= "img_".rand(0,1000).".gif"; ?>) no-repeat top left;">aaaaaaa</div>
create 1000 images in your images folder called /img_1.gif, /img_2.gif etc..

Thanks for your tips. How to make a general random images? I mean when we don't have 1000 images or more than 1000 images.

Thanks a bunch
__________________
US Bank Non Resident - Grab my proven strategy to open US Bank as non Resident NOW!
Reply With Quote
  #4  
Old Aug 26th 2006, 10:17 pm
ccoonen's Avatar
ccoonen ccoonen is offline
of the Nightfall
 
Join Date: Jun 2006
Location: Earth
Posts: 1,485
ccoonen is just really niceccoonen is just really niceccoonen is just really niceccoonen is just really nice
just change url(/images/<?= "img_".rand(0,1000).".gif"; ?>) to however many images you have (make sure to make them in sequencial order)

so if you have 34 images - you would do url(/images/<?= "img_".rand(0,34).".gif"; ?>)
__________________
Find Cheap Furniture # Appleton Wisconsin Plumber - Paul J. Coonen Plumbing
Reply With Quote
  #5  
Old Aug 26th 2006, 11:56 pm
supriyadisw's Avatar
supriyadisw supriyadisw is offline
Champion of the Naaru
 
Join Date: Aug 2006
Location: Jakarta
Posts: 196
supriyadisw is on a distinguished road
Thanks for your help.
__________________
US Bank Non Resident - Grab my proven strategy to open US Bank as non Resident NOW!
Reply With Quote
  #6  
Old Sep 2nd 2006, 10:34 am
SLM-why's Avatar
SLM-why SLM-why is offline
Twilight Vanquisher
 
Join Date: Aug 2006
Location: India
Posts: 879
SLM-why is on a distinguished road
Thanks ccoonen!

I will try that.
Reply With Quote
  #7  
Old Feb 8th 2007, 9:17 am
avanfleet avanfleet is offline
Peon
 
Join Date: Feb 2007
Posts: 1
avanfleet is on a distinguished road
Work with ASP?

I see that this solution works for PHP, but by changing the code to ASP.NET, should it also work?
Reply With Quote
  #8  
Old Feb 8th 2007, 5:20 pm
aplus aplus is offline
Grunt
 
Join Date: Aug 2005
Posts: 76
aplus is on a distinguished road
for image preloading use the method illustrated here:
http://www.phpmysqlapache.com/
Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
css background image not showing in IE rumblepup CSS 9 Jan 16th 2010 11:25 am
CSS Site Background Image (not working in Firefox) yo-yo CSS 9 Oct 23rd 2007 4:37 am
Random header image using CSS sc0ttish CSS 2 May 12th 2006 1:47 pm
Why is IE covering my image with the background image? Ticktockman HTML & Website Design 5 Apr 11th 2006 6:41 am
Random Image Script not so random 313i Programming 8 Oct 26th 2005 5:03 am


All times are GMT -8. The time now is 3:51 pm.