html - 如何在 css 上制作高度为 100% 的 div?

标签 html css

<分区>

大家好! 我想让我的左侧菜单具有 100% 的高度。

右侧将有一个内容区域,右侧还有一个页脚。

我想让左边的浅蓝色菜单到达页面的底部 0。

检查这个 JSFiddle http://jsfiddle.net/mYw72/

或者这段代码!

        <div id="container">
        <div id="top">
            <div id="logo"></div>
            <div id="user-tools">
                <a href="#">Help</a>
                <span>&nbsp;|&nbsp;</span>
                <a href="#">Contact us</a>
            </div>
        </div>

        <div id="sidebar">
            <ul>
                <li><a href="#">Company</a></li>
                <li><a href="">Administrator</a></li>
                <li><a href="#">App</a></li>
                <li><a href="#">Configuration</a></li>
                <li><a href="#">Statistics</a></li>
                <li><a href="#">Monitor</a></li>
                <li><a href="#">Preference</a></li>
            </ul>
        </div>
        <div id="rightSide">
            <div id="content">
                Content.
            </div>

            <div id="bottom1">
                <div id="line-bottom"></div>
                <div id="text-bottom">Copyright 2012 <span>ME</span>, Inc. All Rights Reserved</div> 
            </div>
        </div>
    </div>

css是这样的

html { 
padding:0px;
margin:0px;
}

body {
background-color: #ECEDEF;
font-family: Verdana, Tahoma, Sans-Serif;
color:#564b47;
padding:0px;
margin:0px;
}

#top {
background-image: url('../img/top.png');
background-repeat: repeat-x;
width: 100%;
height: 96px;
}

#rightSide{
overflow: hidden;
}

#sidebar{
position: relative; 
background:lightblue;
border-right:1.7px solid #FFFFFF; 
min-height: 100%;
line-height: 100%;
float: left; 
height:  100%;
margin-top: -5px;
}

#sidebar ul li {
list-style-type: square;
list-style-position: inside;
width:209px;
height:100%;
margin-top:15px;    
}
#sidebar ul li a{
list-style-position: inside;
display: block;
color:#3C3C3C;
text-decoration:none;
font-size:13px;
font-weight:bold;
padding:10px 20px 10px 40px;

}
#sidebar ul li a:hover {
color:#7da536;
width:209px;
border-right: 1.7px solid #ECEDEF;
background: #ECEDEF;
}
#sidebar ul li a:active{
background: #ECEDEF;
border-top: 1.7px solid #D8D9DB;
border-bottom: 1.7px solid #FFF;
border-right: 1.7px solid #FFF;
width:149px;

}

#content{
margin-left: 10px;

}

#bottom {
position: absolute;
bottom: 0;
background-color: #ECEDEF;
width: 100%;
padding: 53px 0 0 0;
}

#bottom1 {
position: absolute;
bottom: 0;
/*background-color: #ECEDEF;*/
background-color: greenyellow;
/*    width: 85.3%;*/
width: 100%;
padding: 53px 0 0 0;

/*    margin-left: 211px;*/
}

最佳答案

html, body, #container { height: 100% }

关于html - 如何在 css 上制作高度为 100% 的 div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15209037/

相关文章:

html - 三重 'Rhomboid' 图像拆分 CSS

javascript - 自定义图像 slider

javascript - 如何在单击按钮时将 HTML 文本框的值(内容)传递给 javascript 函数?

html - 悬停时将 CSS 菜单标题悬停属性更改为橙色

CSS Transition Validation 错误和旧浏览器的支持/解决方案

html - 如何将 2 个文本输入字段合二为一?

css - 无法让 materialboxed 与裁剪后的图像一起使用

html - 图像居中有问题?

html - 验证静态路径,nodejs Express Passport html

javascript - 在所有普通 anchor 标记上使用 jQuery 执行页面加载