[英]Div height is not extending to bottom of page
我正在开发的网站的页面布局如下所示:
-------------------------------------Top Bar-------------------------------------
| |
---------------------------------------------------------------------------------
--------Content (Has a dark filter that goes over the main background image)-----
------------ Main Content---------------------------|-------------SideBar--------
| | |
| | |
| | |
| | |
| | |
| | |
| | |
---------------------------------------------------------------------------------
我页面中的通常是一张照片,出于设计目的,我需要应用深色滤镜。 因此,我创建了一个用于该目的的.content类,所有内容(顶部栏除外)都位于其中。
我的问题是,当.main-content容器中的内容超过页面高度时,筛选器不会到达页面底部。 我的内容高度为100%,还有正文和html标签。
html {
font-size: 16px;
height:100%;
overflow:auto;
}
body {
font-size: 62.5%;
/*10px = 1em*/
line-height: 1.4;
width:100%;
height: 100%;
min-height: 100%;
overflow: auto;
}
.top-bar {
width:100%;
height:58px;
position:fixed;
top:0px;
z-index: 5;
}
.top-bar.user {
background-color:rgba(0, 0, 0, 1);
font-size: 1.2em;
}
.content {
display: block;
margin-top: 58px;
/* = top bar height*/
width: 100%;
height: 100%;
min-height: 100%;
position: absolute;
background-color: rgba(0, 0, 0, 0.3);
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.main-content {
float: left;
width: 75%;
height: 100%;
}
.sidebar {
position: fixed;
right: 0;
width: 25%;
height: 100%;
}
我试图在此处创建问题: http : //jsfiddle.net/apGgd/3/
您是否已看到,随着表格的扩展,过滤器(灰色背景)并未随之移动。 但是,如果您从.content中删除“ height:100%”,则问题将消失。
它起作用的原因是当您删除height:100%
是因为您不需要显式声明它。 你想要的是height:auto; min-height:100%;
height:auto; min-height:100%;
。 这将确保高度至少为100%,但会根据需要填充表格,我认为这是您想要的行为。
您只需删除身高:100%; 从.content部分开始,并添加一个overflow:show;(如果以前的方法不起作用)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.