SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Jul 2010
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    CSS changing background

    I was looking at a site that I would like to copy some of the features. www.glennbeck.com it's background image changes every time you refresh the page and it has a 1700 by 10xx something pixels background image. The Background image seems to conform to what ever the resolution of the computer you are using is and make it look proportioned correctly. I was hoping someone might have some insight for me regarding this. I know several things about css but by no means am an expert.

    Any response valid to my concerns are very much appreciated.

  2. #2
    Non-Member
    Join Date
    Apr 2011
    Location
    no fixed address
    Posts
    851
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could use javascript to generate a random number and then use that number to select a background image from an array of background images. But this won't work in javascript disabled browsers.

    Another option is to put all your bg image files in a separate folder on the server and then add some server side code (like php) to a web page which reads the file names from the bg images folder and then selects one at random. The server side code then sets the selected file name as the bg image in the css code.

  3. #3
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    40,481
    Mentioned
    182 Post(s)
    Tagged
    6 Thread(s)
    Quote Originally Posted by nbham30 View Post
    The Background image seems to conform to what ever the resolution of the computer you are using is and make it look proportioned correctly.
    I only looked at it quickly but they just seem to be using a very large image (1700x 1024). There are some scripts around though to make it fit exactly.

    As webdev said you can do the image swap with js or preferably php and there are a few examples here on
    Google


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •