# Change the background in a div with CSS

**URL:** <https://www.ruby-forum.com/t/change-the-background-in-a-div-with-css/96882>\
**Category:** Rails\
**Created:** [July 3, 2006, 4:41am UTC](https://www.ruby-forum.com/t/change-the-background-in-a-div-with-css/96882 "2006-07-03T04:41:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![imehesz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e47c2d/32.png) [@imehesz](https://www.ruby-forum.com/u/imehesz)\
**Post date:** [July 3, 2006, 4:41am UTC](https://www.ruby-forum.com/t/change-the-background-in-a-div-with-css/96882/1 "2006-07-03T04:41:01Z")

</div>

hello everybody,

i’m just trying to know this RoR better. And I have a question:

- i have a 
 in my scaffold.css and it has a background image. I  
actually have 5 background pictures and i’d like to use one of them  
randomly. Do I have to move this div description in another .rb file  
(where i can do the random pick with ruby?) or is there any other way?

i hope it made sence.

thanks for your help,  
iM

---

<div class="post-metadata">

**Author:** ![imehesz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e47c2d/32.png) [@imehesz](https://www.ruby-forum.com/u/imehesz)\
**Post date:** [July 3, 2006, 6:32am UTC](https://www.ruby-forum.com/t/change-the-background-in-a-div-with-css/96882/2 "2006-07-03T06:32:44Z")

</div>

Javascript to change the style of this div “onload”? - S

imehesz wrote:

> hello everybody,
> 
> i’m just trying to know this RoR better. And I have a question:
> 
> - i have a 
> in my scaffold.css and it has a background image. I  
> actually have 5 background pictures and i’d like to use one of them  
> randomly. Do I have to move this div description in another .rb file  
> (where i can do the random pick with ruby?) or is there any other way?
> 
> i hope it made sence.
> 
> thanks for your help,  
> iM

---

<div class="post-metadata">

**Author:** ![imehesz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e47c2d/32.png) [@imehesz](https://www.ruby-forum.com/u/imehesz)\
**Post date:** [July 3, 2006, 9:04am UTC](https://www.ruby-forum.com/t/change-the-background-in-a-div-with-css/96882/3 "2006-07-03T09:04:04Z")

</div>

imehesz wrote:

> hello everybody,
> 
> i’m just trying to know this RoR better. And I have a question:
> 
> - i have a 
> in my scaffold.css and it has a background image. I  
> actually have 5 background pictures and i’d like to use one of them  
> randomly. Do I have to move this div description in another .rb file  
> (where i can do the random pick with ruby?) or is there any other way?
> 
> i hope it made sence.
> 
> thanks for your help,  
> iM
> 
> Every time you relaod the page “rand(5)” will yeild a different number  
> from 0 - 4, resulting in a random displayed image.

---

<div class="post-metadata">

**Author:** ![imehesz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/e47c2d/32.png) [@imehesz](https://www.ruby-forum.com/u/imehesz)\
**Post date:** [July 3, 2006, 10:03pm UTC](https://www.ruby-forum.com/t/change-the-background-in-a-div-with-css/96882/4 "2006-07-03T22:03:05Z")

</div>

thank you it helped!

iM

> Every time you relaod the page “rand(5)” will yeild a different number  
> from 0 - 4, resulting in a random displayed image.
