第十六课--Float(浮动)

30 阅读1分钟
a.使用浮动
float:right;
float:left;
b.清除浮动
clear:both;
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Float(浮动)</title>
</head>
<style>
     .div1{
        width: 200px;
        height: 200px;
        background-color: #FFA500;
        float: left;
    }
    .div2{
        width: 200px;
        height: 200px;
        background-color: red;
        float: right;
    }
     .div4{
        width: 200px;
        height: 200px;
        background-color: green;
         float: right;
        clear: both;
    }
</style>
<body>
<div></div>
<div class="div1"></div>
<div class="div2"></div>
<div class="div3"></div>
<div class="div4"></div>

</body>
</html>