61,112
社区成员
发帖
与我相关
我的任务
分享
<style>
div{width:100px;height:100px;background:#f90;clear:both}
.left{float:left}
.right{float:right}
</style>
<div class="left"></div>
<div class="right"></div>
<div class="left"></div>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
div{
border: 1px solid #000;
text-align: center;
}
.container{
width: 500px;
height: 500px;
}
.div1, .div2, .div3{
width: 250px;
height: 150px;
}
.div1, .div3{
margin: 5px 0 0 5px;
}
.div2{
margin: 5px 0 0 240px;
}
</style>
</head>
<body>
<div class="container">page
<div class="div1">div1</div>
<div class="div2">div2</div>
<div class="div3">div3</div>
</div>
</body>
</html>
这样?<html>
<head>
<style type="text/css">
.row1 { float: left; color: blue; }
.row2 { color: red }
</style>
</head>
<body>
<div class="row1">第一个div;</div>
<div class="row2">第二个div不换行</div>
</body>
</html>
<!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>无标题文档</title>
<style>
p{margin:0;}
div{height:100px;background:#ccc;}
div p{width:96px;height:96px;border:solid 2px red;}
.box2 p{float:right;}
</style>
</head>
<body>
<div class="box1">
<p></p>
</div>
<div class="box2">
<p></p>
</div>
<div class="box3">
<p></p>
</div>
</body>
</html>
不过如何定高,定位更好控制,只需要设置好top left值即可