SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Wizard
    Join Date
    Apr 2004
    Location
    dublin
    Posts
    2,036
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Random Background Image + CSS

    Hi all,

    I have images stored in a server folder with metadata in Database.

    The images are to be used as Background Images set in a .CSS file...

    background: #fff url('../images/main_bg.jpg');

    How do I display images by random in the CSS file?

    Is it possible?

    Thanks.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    yes, it's possible

    generate the css using your scripting language, which randomly pulls from the metadata in the database

    actually, the better approach would be to have a static css file, which you would bring into the web page with a LINK tag or @import command, and then you would simply add the random background in the css right in the web page --
    Code:
    <style type="text/css"> @import url('static.css'); </style>
    <style type="text/css"> 
    body { background: #fff url('../images/main_bg.jpg'); }
    </style>
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •