<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
.outerDiv{
border: 1px solid blue;
width: 1000px;
height: 500px;
margin: 0px auto;
}
#d1,#d2,#d3{
border: 1px solid red;
width: 400px;
height: 200px;
/*向右 浮动*/
/*float: right;*/
/*向左 浮动*/
float: left;
margin-left:20px;
margin-bottom: 20px;
}
#d1{
background-color: greenyellow;
}
#d2{
background-color:aqua;
}
#d3{
background-color: blueviolet;
}
</style>
</head>
<body>
<div class="outerDiv">
<div id="d1">
<h1>1</h1>
</div>
<div id="d2">
<h1>2</h1>
</div>
<div id="d3">
<h1>3</h1>
</div>
</div>
</body>
</html>
案例
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
.outerDiv{
border: 1px solid blue;
width: 1000px;
height: 500px;
margin: 0px auto;
}
#d1,#d2,#d3{
border: 1px solid red;
width: 400px;
height: 200px;
/*向右 浮动*/
/*float: right;*/
/*向左 浮动*/
float: left;
margin-left:20px;
margin-bottom: 20px;
}
#d1{
background-color: greenyellow;
}
#d2{
background-color:aqua;
}
#d3{
background-color: blueviolet;
}
</style>
</head>
<body>
<div class="outerDiv">
<div id="d1">
<h1>1</h1>
</div>
<div id="d2">
<h1>2</h1>
</div>
<div id="d3">
<h1>3</h1>
</div>
</div>
</body>
</html>