float——都变行内块
- ####加float 变成行内块——在一行,可宽高margin
![](https://img2020.cnblogs.com/blog/2216408/202012/2216408-20201213114444787-182040676.png)
-
div为块元素,无法在一行共存;span设置的宽高无效;
![](https://img2020.cnblogs.com/blog/2216408/202012/2216408-20201213114508690-1748570996.png)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box {
/* float: left; */
width: 300px;
height: 200px;
background-color: pink;
}
span {
/* float: left; */
width: 300px;
height: 200px;
background-color: gray;
}
</style>
</head>
<body>
<div class="box">div盒子</div>
<span>span盒子</span>
</body>
</html>