我试图做有页眉,内容和页脚的布局。页脚必须位于页面底部(完成)。但我的问题是如何获得内容100%strech之间的页眉和页脚。当我的内容为空时,我看不到那个,但是当我在内容div中写入一些内容时,比如“hello”,那么内容只有内容中的内容。我想你可以理解我的意思。 有人可以解释我的CSS代码中有什么问题。内容100%伸展
红色是标题,绿色是页脚,青色是内容,蓝色是容器。问题是内容不包含容器区域。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Praktika1</title>
<link rel="stylesheet" href="style1.css" type="text/css" />
</head>
<body>
<div id="container">
<div id="header">
</div>
<div id="content">
</div>
<div id="footer">
</div>
</div>
</body>
</html>
CSS:
@CHARSET "UTF-8";
*{padding:0; margin:0;}
html,body{
height:100%;
}
#container{
width: 1024px;
position:relative;
background-color:#cce;
margin: 0 auto;
min-height:100%;
}
#header{
width: 1024px;
height:100px;
background-color: #CCC;
}
#content{
height:100%;
width:1024px;
background-color:yellow;
}
#footer{
width: 1024px;
height: 100px;
position:absolute;
bottom:0;
background-color: #ced;
}
突出您的代码,然后单击`{}`按钮。它使您的代码对我们更具可读性。 – Andrew 2011-01-19 16:54:51
你可以发布你的HTML吗? – 2011-01-19 16:55:27
我想在JSfiddle上测试。你打算让我自己写HTML代码吗? `:`` – 2011-01-19 16:56:43