DIV+CSS教程_一行三列的定位浮动问题
代码:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>如何让“copyriht” 居在Left容器底部</title>
</head>
<style>
#wrap { width:1000px;}
#left { width:200px; float:left;position:relative;background:blue;}
#sidebar { width:200px;float:left; position:relative;background:black;}
#content{ width:600px;float:right; position:relative;background:#333;}
</style>
<body>
<div id="wrap">
<div id="left">left<div id="copyright">Copyright</div></div>
<div id="sidebar">center</div>
<div id="content">right</div>
</div>
</body>
</html>
解决方法
如果wrap高度不固定的话,可以在wrap下再加个div,然后#copyright绝对定位,利用top负值缩进。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>如何让“copyriht” 居在Left容器底部</title>
</head>
<style>
body,html{color:#FFF;}
#wrap { width:1000px;}
#left { width:200px; height:500px; float:left;position:relative;background:blue;}
#sidebar { width:200px; height:500px;float:left; position:relative;background:black;}
#content{ width:600px; height:500px;float:right; position:relative;background:#333;}
#footer{position:relative;}
#copyright{position:absolute; top:-45px; left:0}
.clear{clear:both}
</style>
<body>
<div id="wrap">
<div id="left">left</div>
<div id="sidebar">center</div>
<div id="content">right</div>
</div>
<div class="clear"></div>
<div id="footer"><p id="copyright">Copyright</p></div>
</body>
</html>