DIV+CSS教程_一行三列的定位浮动问题
<!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=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" "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=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>
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |