【发布时间】:2017-01-24 03:33:05
【问题描述】:
我正在尝试设置一个网页,但由于元素的高度,我快疯了。 特别是我想要的布局是:
- 顶部有一个固定高度(例如 150 像素)和 100% 宽度的标题。
- 在标题下,我需要两列。左列具有固定宽度(例如 40px),右列与窗口一样大。两列都有最小高度(例如,600 像素,两列相同),但如果有足够的空间,它们必须填满整个窗口,直到页脚。
- 页面底部的页脚。它位于列下方(不得重叠!)并具有固定高度(例如 50 像素)。
我尝试了几种模式,但还没有找到一种可行的模式。有时我最终将页脚叠加在列上,有时列不会填满所有可用空间。 我认为主要问题是最小高度要求,因为没有它问题就相当简单了。我知道 CSS 属性 min-height,但仍然找不到方法。
这是我的代码(无法正常工作,右栏变得太大,页脚甚至不显示)。
header{
height: 40px;
width: 100%;
background-color: darkgoldenrod;
text-align: center;
}
footer{
background-color: grey;
height: 50px;
width: 100%;
text-align: center;
}
#container{
position: relative;
width: 100%;
min-height: 200px;
background-color: red;
margin-bottom: -100px;
padding-bottom: 100px;
}
#toolbar{
background-color: white;
position: absolute;
left: 0;
width: 80px;
height: 100%;
}
#drawbox{
background-color: yellow;
height: 100%;
width: 100%;
position: absolute;
left: 80px;
}
<!DOCTYPE html>
<html>
<head>
<title>BLOCKS</title>
<link rel="stylesheet" type="text/css" href="blocchi.css">
</head>
<body>
<header>
<h2>HEADER</h3>
</header>
<div id="container">
<aside id="toolbar">TOOLBAR</aside>
<div id="drawbox">DRAWBOX</div>
</div>
<footer>
<p>FOOTER</p>
</footer>
</body>
</html>
你能帮帮我吗?提前致谢!
编辑:如果可能的话,我想要一个不涉及 CSS3 属性和异国情调的答案,因为我正在尝试了解简单的事情是如何工作的。 我很确定解决方案是“div”、“position”、“height”和类似内容的组合!
【问题讨论】:
-
发布您正在尝试的当前 HTML 和 CSS。
-
@Atrix 完成了,尽管它并没有明显工作。