2010-10-28 66 views
0

我有CSS代码做布局。我有基本的页眉面板,页脚,左侧面板和中央面板。我想让左侧面板和中央面板自动拉伸到底部(蓝色和灰色部分一直到黑色底部)。有没有办法做到这一点? 以下是我的代码。CSS布局100%的高度延伸到底部吧

谢谢你,

alt text



body { 
    text-align: center; 
} 
.wrapper { 
    position: relative; 
    width: 960px; 
    font-size: 0.9em; 
    margin: 0 auto -20px; 
    text-align: left; 
} 
.header { 
    height: 125px; 
    background-color:purple; 
} 
.footer { 
    position: relative; 
    width: 960px; 
    margin: 0 auto; 
    background-color:black; 
} 
.footer a { 
    color: #fff; 
    text-decoration: underline; 
    border: 0; 
} 
.footer p { 
    position: absolute; 
    left: 0; 
    bottom: 4px; 
    width: 960px; 
    padding: 0; 
    color: #fff; 
    font: 0.8em arial,sans-serif; 
    text-align: center; 
} 
html, body { 
    height: 100%; 
} 
.wrapper { 
    min-height: 100%; 
    height: auto !important; 
    height: 100%; 
    margin: 0 auto -20px; /* the bottom margin is the negative value of the footer's height */ 
    background-color:yellow; 

} 
.footer, .push { 
    height: 20px; /* .push must be the same height as .footer */ 
} 
.leftPanel{ 
    width:200px; 
    background-color:blue; 
    float:left; 
    height: 100%; 
} 
.centerPanel{ 
    width:760px; 
    background-color:gray; 
    float:left; 
    height: 100%; 

} 

dl,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,body,html,div,p,blockquote,fieldset,legend,input,select,textarea 
{ margin:0; padding:0 } 


<div class="wrapper"> <div class="header"> <h1>header</h1> </div> <div class="leftPanel"> leftPanel </div> <div class="centerPanel"> center Panel </div> <div class="push"></div> </div> <div class="footer"> <p>footer</p> </div> </body>

回答

1

获得元素可拉伸至视口是的高度的比例部分的唯一方法将它们锚定在底部。

See here查看具体信息。

+0

我试过的建议。但它隐藏了标题。
这是屏幕截图 http://i.imgur.com/NxN0Z.jpg%22%20title=%22Hosted%20by%20imgur.com%22%3Ehttp://imgur.com/NxN0Z.jpg
.leftPanel { \t width:200px; \t background-color:blue; \t float:left; \t position:absolute; \t身高:100%; \t bottom:20px; \t margin-top:300px; } .centerPanel { \t width:760px; \t background-color:gray; \t position:absolute; \t身高:100%; \t margin-top:300px; \t left:200px; \t bottom:20px; } – 2010-10-28 18:55:48

+0

我想我可能得到了错误的确切规则;但是这个概念站得住脚查看实际交易的添加链接。 – 2010-10-29 06:14:24