Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS [Solved] Rotating BG in CSS and center BG

  • This topic is empty.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #30013
    telters
    Member

    Hi there

    I have a website that needs a different background to display every time a user reloads the page. How can I do this in CSS?

    ALSO

    How can I make sure that background is centered in the middle of the page (vertically and horizontally), and if the user has a larger screen, it will be white around the image.

    THANKS!

    #81688
    TheDoc
    Member

    The rotation can be accomplished with some fairly basic PHP. I haven’t tried the following method, but it looks like a nice choice:

    http://sonspring.com/journal/easy-random-css-backgrounds

    Centering the background:

    body {
    background: url(path/to/image.jpg) top center no-repeat;
    }
    #81675
    telters
    Member

    Awesome! Thank you so much!

    #81668
    TheDoc
    Member

    Oh, and to make sure white will be the color that goes around it, do this:

    body {
    background: url(path/to/image.jpg) top center no-repeat #fff;
    }
    #81670
    telters
    Member

    Ok, now I’m having a problem

    Check out this page This Page

    User:user
    Pass:user

    On my computer, and another computer, I have to reload the page a few times just to make the background image pop up. Do you know why this is hapenning?

    #81633
    telters
    Member

    Ok, So what you guys are saying is that I need more images to be in the folder, and that I need to add code making sure that the browser deletes cookies when visitng the page.

    How do I make that code? I have no clue what to do in PHP, I only every use CSS and Html

    #81595
    telters
    Member

    Awesome!

    Thanks!

Viewing 7 posts - 1 through 7 (of 7 total)
  • The forum ‘CSS’ is closed to new topics and replies.