Boa*_*rdy 7 html css html5 css3
我目前正在开发HTML5和CSS项目,并且在使容器正确显示时遇到问题.
我想要的是顶部的标题栏,包含2个其他div的包装,然后是底部的页脚,它始终位于窗口底部或内容的底部,以较低者为准.
这是一个片段:
html, body
{
	padding: 0;
	margin: 0;
}
#wrapper
{
	position: absolute;
	background-color: purple;
	height: 100%;
	width: 100%;
	margin-top: 0px;
}
header
{
	position: absolute;
	width: 100%;
	height: 80px;
	background-color: black;
	color: white;
}
#articleContainer
{
	background-color: blue;
	width: 75%;
	margin-left: auto;
	margin-right: auto;
	height: auto;
	margin-top: 80px;
}
#articleContent
{
	width: 70%;
	background-color: yellow;
	float: left;
}
#articleSideBar
{
	position: relative;
	width: 28%;
	background-color: green;
	float: right;
	margin-left: 2px;
	margin-right: 2px;
	display: inline;
	margin-top: 0px;
	float: right;
	height: auto;
}<html>
	<head>
		<title>index</title>
		<link href="ArticleStyleSheet.css" rel="stylesheet" type="text/css" />
	</head>
	<body>
		<div id="wrapper">
			<header>
				Header
			</header>
			<div id="articleContainer">
				Article Container
				
				<div id="articleContent">
					The quick brown fox jumped over the lazy dogs back. All good men must come to the aid of the party
				</div>
				
				<div id="articleSidebar">
					Article Sidebar
				</div>
			</div>
		</div>
	</body>
</html>目前,articleContainer只有很多行的高度.我想要的是formContainer来填充屏幕的其余部分,我尝试添加高度:100%; 属性,但然后这感觉形式容器超过屏幕大小.即出现垂直滚动条,其高度与标题大致相同.如何在没有滚动条的情况下让formContainer填充可用的屏幕空间.但是,如果内容大于表单容器应扩展以填充额外空间.
感谢您的任何帮助,您可以提供.
如果你真的想要一个CSS3解决方案,您正在寻找的是设置一个height: calc(100% - 80px);关于#articleContainer在证明这个小提琴,但是这并不会在所有的浏览器.
使用旧的flexbox模型 css的示例:
html, body
{
    padding: 0;
    margin: 0;
    height: 100%;
}
#wrapper
{
    display: -webkit-box;
    -webkit-box-orient: vertical;
    min-height: 100%;
    background-color: purple;
    width: 100%;
    margin-top: 0px;
}
header
{
    width: 100%;
    height: 80px;
    background-color: black;
    color: white;
}
#articleContainer {
    width: 75%;
    margin: auto;
    background-color: blue;
    display: -webkit-box;
    -webkit-box-flex: 1;
}
#articleContent
{
    width: 70%;
    background-color: yellow;
}
#articleSideBar
{
    position: relative;
    width: 28%;
    background-color: green;
    margin-left: 2px;
    margin-right: 2px;
    display: inline;
    margin-top: 0px;
    height: auto;
}?
同样的事情,但这次使用新的flexbox模型 css
html, body
{
    padding: 0;
    margin: 0;
    height: 100%;
}
#wrapper
{
    display: -webkit-flex;
    -webkit-flex-direction: column;
    min-height: 100%;
    background-color: purple;
    width: 100%;
    margin-top: 0px;
}
header
{
    width: 100%;
    height: 80px;
    background-color: black;
    color: white;
}
#articleContainer {
    width: 75%;
    margin: auto;
    background-color: blue;
    display: -webkit-flex;
    -webkit-flex: 1;
}
#articleContent
{
    width: 70%;
    background-color: yellow;
}
#articleSideBar
{
    position: relative;
    width: 28%;
    background-color: green;
    margin-left: 2px;
    margin-right: 2px;
    display: inline;
    margin-top: 0px;
    height: auto;
}?