2011-06-14 87 views
0

我的代码被粘贴下来。我希望div“目标”被定位在div“conten区域”的底部。标题也应该粘在浏览器的顶部,页脚应该粘在浏览器的底部。在内容div的底部放置一个div

希望它是有道理的。

在此先感谢!

<!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> 

回答

1

你是否在这样的事情?

http://jsbin.com/azebu5

它是如何工作的? 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>