开发者

CSS and jQuery: document.height not reporting properly? div won't stretch vertically

开发者 https://www.devze.com 2023-02-11 11:12 出处:网络
开发者_JAVA百科Oddly enough I can\'t seem to find anyone with this issue. O_o Pastebin Code leaves a gap between the end of #main and the end of the actual page on IE, Chrome (and Safari), but not
开发者_JAVA百科

Oddly enough I can't seem to find anyone with this issue. O_o

Pastebin

Code leaves a gap between the end of #main and the end of the actual page on IE, Chrome (and Safari), but not on Firefox.

Vanilla CSS has html, body{ min-height: 100%; height: auto !important; }. #content is position: relative inside #main.

Trying to get #main to stretch from the top to the bottom of the page.

Edit: After playing with it more, it seems to me that everything depends on #content having its entire content loaded before the CSS-change calculations take place. Switching from one page to another allows Chrome (and Safari) to set the proper height for #main. Is there any way I can 'tell the code to wait'? Although I'm not sure if this fixes the problem with IE


<html>
    <body>
        <div id="main">
            <div id="content">
                <p>content area</p>
            </div>
        </div>
    </body>
</html>

And the CSS

html, body {height: 100%; margin: 0; padding: 0}
#main {
    min-height: 100%;
    height: auto !important;
    width: 1024px;
    position: absolute;
    top:0; 
    left:50%;
    margin-left:-512px
}
#content {margin: 135px 0 0 300px}

/* for illustrative purposes */
#main {background-color: #CDE}

Check out the fiddle
http://jsfiddle.net/UB975/6/

0

精彩评论

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

关注公众号