2018-06-10 清除浮动

清除浮动以下几种方式:

1:使用伪类标签

2:添加一个多余的div

3:添加br标签使用其clear="all"属性

4:父元素设置overflow:hidden

5:父元素设置display: table

.clear::after{

display: block;

content: '.';

height: 0px;

visibility: hidden;

clear: both;

   }

第一种: 清除浮动 使用伪类标签

 <div class="clear">

<div style="position: left;width: 50px;height: 60px;background-color: red"></div>

<div style="position: left;width: 50px;height: 60px;background-color: yellow"></div>

</div>

  第二种 添加额外的标签

<div>

<div style="position: left;width: 50px;height: 60px;background-color: red"></div>

<div style="position: left;width: 50px;height: 60px;background-color: yellow"></div>

<div style="clear: both"></div>

</div>

    第三种 父类标签设置overflow 

<div style="overflow: hidden">

<div style="position: left;width: 50px;height: 60px;background-color: red"></div>

<div style="position: left;width: 50px;height: 60px;background-color: yellow"></div>

</div>

      第四种 父类标签设置设置为table

<div style="display: table">

<div style="position: left;width: 50px;height: 60px;background-color: red"></div>

<div style="position: left;width: 50px;height: 60px;background-color: yellow"></div>

</div>

第五种 添加br标签

<div>

<div style="position: left;width: 50px;height: 60px;background-color: red"></div>

<div style="position: left;width: 50px;height: 60px;background-color: yellow"></div>

</br clear="all">

</div>

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 问答题47 /72 常见浏览器兼容性问题与解决方案? 参考答案 (1)浏览器兼容问题一:不同浏览器的标签默认的外补...
    _Yfling阅读 14,178评论 1 92
  • 这篇文章极好,以至于让我受益良多,就一字没有改动的转发过来一丝冰凉老师的文章 需要注意的是,display:tab...
    新晋小牛牛阅读 1,133评论 0 2
  • 第一部分 HTML&CSS整理答案 1. 什么是HTML5? 答:HTML5是最新的HTML标准。 注意:讲述HT...
    kismetajun阅读 28,846评论 1 45
  • 浏览器与服务器的基本概念 浏览器(安装在电脑里面的一个软件) 作用: ①将网页内容渲染呈现给用户查看。 ②让用户通...
    云还灬阅读 1,284评论 0 0
  • 2018年4月29日 星期日 晴 昨天晚上睡觉之前,鑫瑶关切地问:妈妈,亲子日记大部队写到第几篇了?我说:写到14...
    书简liu阅读 191评论 0 0

友情链接更多精彩内容