SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Jun 2001
    Location
    Southampton, UK
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    background image to DIV using css?

    is it possible to add a background image to a <DIV> using css?

  2. #2
    Captain Internet neil's Avatar
    Join Date
    Jun 2001
    Location
    n.ireland
    Posts
    333
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    background-image: url(blah.jpg);

    It should work out like:
    <div style="background-image: url(blah.jpg);">
    neil - Geocities, the trailer park of the web
    .<.<.<.<.<.<.<.<
    WEB[retype.net] + [guff.org]
    ICQ[273981] AIM[neiim]

  3. #3
    pg for mild peril cow's Avatar
    Join Date
    Mar 2000
    Location
    nevada, usa
    Posts
    636
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sure. in the class definition that you use for your <div>, just add background-image: url(); with the location of the image you want to add.

    you can also use background-repeat and background-position to fine tune it...
    "There's no justice like angry mob justice!" --Seymour Skinner

  4. #4
    SitePoint Zealot
    Join Date
    Jun 2001
    Location
    Southampton, UK
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    how about if i want to add that code into my external style sheet?

  5. #5
    SitePoint Member [MOS]'s Avatar
    Join Date
    Jun 2001
    Location
    Madrid, Spain
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    #myDiv {
    background: #666 url(/images/bgimage.gif) repeat-y;
    font-size: 12px;
    line-height: 14px;
    padding: 2px;
    }
    That would make a DIV with background color #666, bgimage.gif repeating only vertically (so the rest of the DIV would be coloured #666) and some other CSS rules.

    Hope it helps.
    Carlos de la Orden
    The higher a man gets, the smaller he looks for people who can't fly.

    www.aspfacil.com, el sitio para programadores ASP

  6. #6
    SitePoint Zealot
    Join Date
    Jun 2001
    Location
    Southampton, UK
    Posts
    121
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    nice one - thanks


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
  •