css浮动

右浮动,让该元素尽量的往右移动,直到碰到父元素的边界

 左浮动

eg:记住下面的特点 

 h4.html

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <link rel="stylesheet" type="text/css"href="css/float1.css"/>
    </head>
    <body>
        <div class="div3">
        <div  class="div2">divceshi</div>
        <div class="div1" >div1</div>
            <div class="div1">div1</div>
                <div class="div1" id="div2">div1</div>
        <div class="div1" >div1</div>
            <div class="div1">div1</div>
        </div>
    </body>
</html>
View Code

flloat.css

.div1{
    width: 150px;
    height: 100px;
    border: 1px solid blue;
    background: pink;
    margin-top:5px;
    float: left;./*左浮动*/
}

.div2{
    width:150px ;
    height: 120px;
    border: 1px solid red;
    background: green;
    float: left;
}
.div3{
width: 600px;
height: 600px;
border: 1px solid green;    
}
View Code

 

posted @ 2019-05-23 10:08  Hello_World2020  阅读(90)  评论(0编辑  收藏  举报