leiyanting

导航

 
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title></title>
        <style type="text/css">
            *{
                margin: 0;
                padding: 0;
            }
            /* 
                如果希望块元素在页面中水平排列,可以使块元素脱离文档流
                使用float来使元素浮动,从而脱离文档流
                    可选值:
                        none: 默认值,元素默认在文档流中排列
                        left: 元素会立即脱离文档流,想页面的左侧浮动
                        right: 元素会立即脱离文档流,想页面的右侧浮动
                
                当为一个元素设置浮动后
                    元素立即脱离文档流,元素脱离文档流以后,他下面的元素会立即向上移动
                    元素浮动以后,会尽量向页面的左上或右上浮动,直到遇到父元素的边框,或者其他的浮动元素                    
                    如果浮动元素上边是一个没有浮动的块元素,则浮动元素不会超过块元素
                    浮动的元素不会超过他上边的兄弟元素,最多一边齐
             */
            .box1{
                width: 200px;
                height: 200px;
                background-color: red;
            }
            .box2{
                width: 200px;
                height: 200px;
                background-color: yellow;
            }
            .box3{
                width: 200px;
                height: 200px;
                background-color: blue;
            }
            
            div{
                float: left;
            }
            
        </style>
    </head>
    <body>
        <div class="box1"></div>
        <div class="box2"></div>
        <div class="box3"></div>
    </body>
</html>

 

posted on 2021-07-01 10:35  leiyanting  阅读(101)  评论(0)    收藏  举报