Background image doesn't repeat when browser window is smaller than content?

后端 未结 6 1527
小鲜肉
小鲜肉 2020-12-20 15:37

I have a header-container with a background image, like so:

#header-container
{
background:url(../img/bg.jpg) repeat-x 0 0px;
margin:0px auto;
width:100%;
te         


        
6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-20 16:32

    As animuson mentioned in a comment, it's more likely if you have a set min-width or just some content that expands the page over it's available borders.

    There is an example of the second one: http://jsfiddle.net/kizu/3hLjv/

    To fix the second one, you can make the wrapper to have width set by it's children, for example, you can use inline-block for this: http://jsfiddle.net/kizu/3hLjv/1/, if you have no wrapper, you can set this to BODY: http://jsfiddle.net/kizu/3hLjv/2/

    And if you have some blocks with widths or min-widths greater than header's, just add the same min-width to header: http://jsfiddle.net/kizu/3hLjv/3/

提交回复
热议问题