Question: ```
html{ 
    background: url(/assets/flower.jpg) no-repeat center center fixed; 
    -webkit-background-size: cover;   
    -moz-background-size: cover;
    -o-background-size: cover;
    background-size: cover;
}

```

How can I make this code randomly choose from a selected number of pictures as background. I am using Rails 3, so have that in mind, if that will simplify the process of making this work.
THANKS! :D

Answer: 
In your view file where you would like to display the background image, add this line

```
<style type="text/css">
  html {
    background: url(<%= randomized_background_image %>) no-repeat center center fixed; 
  }
</style>

```

Now in your application\_helper

```
def randomized_background_image
  images = ["assets/foo.jpg", "assets/random.jpg", "assets/super_random"]
  images[rand(images.size)]
end

```
I did this by creating a random class name in the view like this:

```
<div class="homepage-banner-<%= rand(1..10) %>">

```

Then I just added multiple images to my css like this:

```
.homepage-banner-1
  background-image: image-url('homepage/homepage-feature-1.jpg')

.homepage-banner-2
  background-image: image-url('homepage/homepage-feature-2.jpg')

.homepage-banner-3
  background-image: image-url('homepage/homepage-feature-3.jpg')

etc.

```

Not sure if that's the best way, but it's very simple.