Please help - background image not working

Discussion in 'CSS' started by ketting00, Apr 23, 2011.

  1. #1
    Hi,

    What went wrong with my coding:confused:

    I test it with this and it works fine: <img src="images/shadow.png" />.

    But it's not working with this css snippet: background: url(images/shadow.png) bottom center no-repeat;

    Please help me and thanks in advance.
     
    ketting00, Apr 23, 2011 IP
  2. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #2
    There is nothing wrong with that.

    The container may not have enough height to show the background. Fill it with content or give it a height.
    An incorrect selector name is another reason.
     
    Cash Nebula, Apr 23, 2011 IP
  3. Zetiz

    Zetiz Active Member

    Messages:
    668
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    80
    #3
    use the following:

    
    background: url('../images/shadow.png') bottom center no-repeat;
    
    Code (markup):
    Hope it works! :)
     
    Zetiz, Apr 23, 2011 IP
  4. ketting00

    ketting00 Well-Known Member

    Messages:
    782
    Likes Received:
    28
    Best Answers:
    3
    Trophy Points:
    128
    #4
    The image appears everywhere when calling with the <img> tag, but nowhere with the css background snippet. This is so weird. I've made it appeared fine before. The background disappeared when I recode the PHP and replaced it with <?php header('Location: welcome.php'); ?> for <?php include('welcome.php'); ?>.

    There must be something change with the URL or the <div>. But I can't figure out.
     
    ketting00, Apr 23, 2011 IP
  5. ketting00

    ketting00 Well-Known Member

    Messages:
    782
    Likes Received:
    28
    Best Answers:
    3
    Trophy Points:
    128
    #5
    On experiment it works fine to put these lines between the <header></header> tags:

    <style type="text/css">
    #image_holder {background: url(images/shadow.png) bottom center no-repeat;
    width: 960px;
    height: 600px;}
    </style>

    But it does not work in a stylesheet. Why is this?
     
    ketting00, Apr 23, 2011 IP
  6. Cash Nebula

    Cash Nebula Peon

    Messages:
    1,197
    Likes Received:
    67
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Do you have a stylesheet link in the head section? If so, check that it's being loaded.
    Better yes, show us the full code for the page.
     
    Cash Nebula, Apr 24, 2011 IP
  7. ketting00

    ketting00 Well-Known Member

    Messages:
    782
    Likes Received:
    28
    Best Answers:
    3
    Trophy Points:
    128
    #7
    Never mind I did manage to have it shown up with the old fashion of:
    <style type="text/css">
    #image_holder {background: url(images/shadow.png) bottom center no-repeat;
    width: 960px;
    height: 600px;}

    in a separated PHP file.
    </style>
     
    ketting00, Apr 24, 2011 IP