2

我发现很少有关于 100% 高度和粘性页脚的教程。但是,我无法实现 100% 高度的右侧边栏。我的侧边栏的高度似乎与侧边栏中的内容相关,即使它设置为 100%。有任何想法吗?

这是我的html

    <body>
    <div id="container">
<div id="header">
</div>
   <div id="wrap">
        <div id="sidebar-right">
            <div id="menu">
                  lorem ipsum
              </div>
        </div>
        <div id="content">
        Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus adipiscing, nunc quis vehicula vehicula, mi nunc tempor lorem, nec congue augue neque vitae augue. 
   </div>
<div class="push"></div>
</div>
<div class="footer">
</div>
</body>

和 CSS

html, body{margin: 0; padding: 0; height: 100%;}
#sidebar-right{
    background: #ccc;
    float: right;
    height: 100%;
    width: 300px;
    border-left: 2px #fff solid;
}
#container{
height: auto !important;
    margin: 0 auto -142px;
    min-height: 100%;
}

#wrap {
    height: 100%;
    overflow: hidden;
    }

#menu {margin: 150px 0 0 50px;} 

.footer {
    background: none repeat scroll 0 0 #BA6F19;
    clear: both;
    height: 100px;
    position: relative;
}   

#header {
    background: none repeat scroll 0 0 #BA6F19;
    height: 50px;
    padding: 20px;
}
#content {
    float: right;
    margin-top: 100px;
    width: 400px;
    height: 100%
    }
.footer, .push {
    height: 142px;
}   
4

1 回答 1

1
#sidebar-right{
    background: #ccc;
    float: right;
    height: 100% !important;
    width: 300px;
    border-left: 2px #fff solid;
}

尝试这个?

于 2012-07-21T12:00:21.470 回答