代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box1{
float: left;
width: 200px;
height: 200px;
background-color: pink;
}
.box2{
width: 300px;
height: 300px;
background-color: rgb(0, 153, 255)
}
</style>
</head>
<body>
<div class="box1">浮动的盒子</div>
<div class="box2">标准流的盒子</div>
</body>
</html>
运行效果
加上浮动的盒子会浮动半空中,位置不在保留
如果另一个盒子没有加上浮动,会跑到底下