HTML中浮动(float)的使用2---脱标

时间:2020-03-23 15:04:39   收藏:0   阅读:70

浮动元素的脱标(脱离标准流)

<style type="text/css">
            .box1{width: 100px;height: 100px;background-color: aqua;
                  float: left;
            }
            .box2{width: 150px;height: 150px;background-color: brown;
                  
            }
            
            
        </style>
    </head>
    <body>
        <div class="box1"></div>
        <div class="box2"></div>
    </body>

技术图片

 

因为我们将box1进行了左浮动,box1脱离了标准流,但是box2补上了box1的标准流位置

 

 

 

 

 

技术图片

 

 

<style type="text/css">
            .box1{width: 100px;height: 100px;background-color: aqua;
                  float: left;
            }
            .box2{width: 150px;height: 150px;background-color: brown;
                  
            }
            
            
        </style>
    </head>
    <body>
        <div class="box1"></div>
        <div class="box2">我是文字我是文字我是文字我是文字我是文字我是文字我是文字我是文字</div>
    </body>

 

 浮动元素的字围现象,没有浮动的元素中的文字会给我们浮动元素让位置

 

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!