我的代码被粘贴了。我希望div“目标”位于div“conten area”的底部。标题也应该贴在浏览器的顶部,页脚应该粘在浏览器的底部。
希望它有意义。
提前致谢!!!
<!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>test</title>
</head>
<style>
#page-wrapper{}
#header{ background:#000; height:100px}
#content{ min-height:100%;}
#target{ background:#ebebeb; }
#footer{background:#000; height:40px}
</style>
<body>
<div id="page-wrapper">
<div id="header">header goes here</div>
<div id="content">
<div id="target">You need to fix me</div>
</div>
<div id="footer">Content for New Div Tag Goes Here</div>
</div>
</body>
</html>
答案 0 :(得分:1)
你是否经历过这样的事情?
它是如何工作的? http://css-tricks.com/absolute-positioning-inside-relative-positioning/
<!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>test</title>
</head>
<style>
html,body{margin:0;padding:0}
#page-wrapper{position:absolute;top:0;bottom:0;left:0;right:0}
#header{ background:cyan; height:100px; position:absolute; top:0; left:0; width:100%}
#content{ position:absolute; background:#eee; top:100px; bottom:40px; left:0; right:0}
#target{ background:yellow; position:absolute; bottom:0; left:0; width: 100% }
#footer{background:red; height:40px; position:absolute; bottom:0; left:0; width:100%}
</style>
<body>
<div id="page-wrapper">
<div id="header">header goes here</div>
<div id="content">
<div id="target">You need to fix me</div>
</div>
<div id="footer">Content for New Div Tag Goes Here</div>
</div>
</body>
</html>