开发者

Does Blueprint prevent a 100% background-size for images in CSS?

I'm trying to create a website with a background-size:100% 100% css rule. It's an image that sits behind the content and is designed in such a way that no matter the dimensions of the browser window it still works well.

I think the rule I have (as below) is clashing with Blueprint somehow.

body { 
    background:url('../img/bg.jpg') no-repeat; 
    background-size:100% 100%; 
    -moz-background-size:100% 100%; 
    -webkit-background-size:100% 100%; 
}

This should generate a perfect 100% background image, however, the results I'm getting is that the background finishes where the content finishes, regardless of the browser window size.

Here are two images of what I want and what I'm getting:

EXPECTED

Does Blueprint prevent a 100% background-size for images in CSS?

WHAT I'M GETTING (regardless of browser size)

Does Blueprint prevent a 100% background-size for images in CSS?

Please help me, I'm not sure how to proceed with this.

Here is my HTML setup for the page:

<body>
    <div class="container">
        <div id="navbar" class="span-6 last">
            <div id="logo" class="span-6 last"></div>
            <div id="menu">
                <ul>
                    <li clas开发者_C百科s="menu-current"><a href="index.php">Home</a></li>
                    <li><a href="aboutus.php">About Us</a></li>
                    <li><a href="services.php">Services</a></li>
                    <li><a href="contact.php">Contact Us</a></li>
                </ul>
            </div>
        </div>
        <div id="content" class="span-18 last">

        </div>
    </div>
</body>

If the container is 550px high then the background ends 550px down the page with an empty white space beneath that area.

I was able to replicate the effect on JSFiddle:

http://jsfiddle.net/danhanly/TurW5/4/


Would be nice if you can show us your HTML and CSS that way maybe I can pin point what your doing wrong.

You can write.

html {height:100%}
body {background:url('/image.jpg') no-repeat center}
#container {
    margin:20px auto;
    width:960px;
    overflow:hidden}


Adding a min-height to the body that is equal to the height of the background-image will ensure that the body is large enough to display the entire background.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜