<!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>
.one{
width: 200px;
height: 200px;
background-color: blue;
}
.two{
width: 200px;
height: 200px;
background-color: red;
}
.two,.one{
float:right;
}
</style>
</head>
<body>
<div class="container">
<div class="one"></div>
<div class="two"></div>
</div>
</body>
</html>
为什么不是红色的在右边,蓝色的在左边
html代码的渲染都是从左至右滴,所以你不管是向左还是向右浮动,你的页面渲染顺序是和代码顺序是一致的,即div-1、2。