<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.box1 {width: 100px; height: 100px; background: orange; float: left;}
.box2 {width: 100px; height: 100px; background: red; float: left;}
.box3 {width: 100px; height: 100px; background: blue; float: left;}
.box4 {width: 100px; height: 100px; background: green; float: left;}
</style>
<!--
浮动 float
作用是水平布局
float: left ;向左浮动
float: right ;向右浮动
如果有一个设置浮动 四个都需要设置浮动 要么全向左要么全向右
全向右的时候 box1会变成最右边的 比较特殊 ,一般不会设置全部向右
清浮动: clear:both
clear:left/right/both
解决浮动带来的div重叠的影响
-->
</head>
<body>
<div class = "box1">box1</div>
<div class = "box2">box2</div>
<div class = "box3">box3</div>
<div class = "box4">box4</div>
<div style = "clear: both; width: 600px; height: 300px; background: pink;">hello</div>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
.box1 {width: 100px; height: 100px; background: orange; float: left;}
.box2 {width: 100px; height: 100px; background: red; float: left;}
.box3 {width: 100px; height: 100px; background: blue; float: left;}
.box4 {width: 100px; height: 100px; background: green; float: left;}
</style>
<!--
浮动 float
作用是水平布局
float: left ;向左浮动
float: right ;向右浮动
如果有一个设置浮动 四个都需要设置浮动 要么全向左要么全向右
全向右的时候 box1会变成最右边的 比较特殊 ,一般不会设置全部向右
清浮动: clear:both
clear:left/right/both
解决浮动带来的div重叠的影响
-->
</head>
<body>
<div class = "box1">box1</div>
<div class = "box2">box2</div>
<div class = "box3">box3</div>
<div class = "box4">box4</div>
<div style = "clear: both; width: 600px; height: 300px; background: pink;">hello</div>
</body>
</html>