码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2020-03-23 15:04:39      阅读:70      评论:0      收藏:0      [点我收藏+]

标签:为我   alt   css   image   使用   body   元素   mamicode   浮动   

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

<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>

 

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

 

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

标签:为我   alt   css   image   使用   body   元素   mamicode   浮动   

原文地址:https://www.cnblogs.com/chen-wei123/p/12551952.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!