0

I have a strange problem that I can't get my head around:

I have a header div and I would like to display a background image to be repeated horizontally:

The HTML:

<div id="headerwrapper">

     <div id="header">
          <p>This is an extremely interesting test. This is an extremely interesting test. This is an extremely interesting test.</p>
     </div>

</div>

Here is the CSS:

* {
    margin:0;
    padding:0;
}

#headerwrapper {
    margin:0 auto;
    width:630px;    
}

#header {
    width:630px;
    background-image:url(../images/headermiddleback.jpg);
    background-repeat:repeat-x;
}

When I look at it in the browser, I can see only 1 instance of the background-image being displayed above the text. But it is not repeating.

Any idea what I am doing wrong here?

BrokenCode
  • 795
  • 4
  • 13
  • 28

3 Answers3

0

Here is your example on jsFiddle, seems to be working. http://jsfiddle.net/MgvLT/1/

Perhaps you have some other CSS that's getting into the way or maybe your background image has lots of empty space. Please post your example on jsFiddle.

Dmitry Pashkevich
  • 12,206
  • 9
  • 49
  • 68
  • Your jsfiddle example is working perfectly for me (using Google Chrome). I tried increasing the width of #header so I can see if background image gets repeated and it does. What browser are you using? – Dmitry Pashkevich May 27 '12 at 09:53
  • Strange, I am using FF 12.0 on Mac – BrokenCode May 27 '12 at 09:54
  • I just emptied the cache, and still it's not working. Could this have something to do with the fact that it is running off a MAMP instance on my Mac? – BrokenCode May 27 '12 at 09:56
  • MAMP should have nothing to do with it. Are you sure you really want `repeat-x` instead of `repeat-y` as suggested above? – Dmitry Pashkevich May 27 '12 at 09:59
  • Check the above [jsFiddle](http://jsfiddle.net/hsTPU/4/). I believe this is a case of mistaking horizontal repeat for vertical repeat. – arttronics May 27 '12 at 10:01
  • Oh my God. You guys are right. I'm so sorry, in shame I must admit I have been trying to get this to work for the past hour and never even considered that I mixed up x and y... Thank you so much :) – BrokenCode May 27 '12 at 10:02
0

Perhaps you need to clear your browsers cache?

For example, here's a SO Post showing how to do it for Chrome.

Community
  • 1
  • 1
arttronics
  • 9,907
  • 2
  • 24
  • 59
0

You might want to use repeat-y instead of repeat-x

#header {
    width:630px;
    background-image:url(http://dl.dropbox.com/u/4457768/css/headermiddleback.jpg);
    background-repeat:repeat-y;
}
Zoltan Toth
  • 45,022
  • 11
  • 108
  • 129