美文网首页
2018-06-10 清除浮动

2018-06-10 清除浮动

作者: 忙于未来的民工 | 来源:发表于2018-10-26 15:50 被阅读0次

清除浮动以下几种方式:

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>

相关文章

  • 2018-06-10 清除浮动

    清除浮动以下几种方式: 1:使用伪类标签 2:添加一个多余的div 3:添加br标签使用其clear="all"属...

  • 11.22 前端学习

    清除浮动 clear:left清除左浮动clear:right清除右浮动clear:both清除对它影响最大的浮动...

  • 前端06

    清除浮动 clear:left清除左浮动clear:right清除右浮动clear:both清除对它影响最大的浮动...

  • 06 前端学习

    清除浮动 clear:left清除左浮动clear:right清除右浮动clear:both清除对它影响最大的浮动...

  • 清除浮动

    未清除浮动前 清除浮动后

  • 技术知识点整理

    清除浮动 BFC清除浮动浮动的父级末尾插入块级元素清除浮动 BFC(Block Formatting Contex...

  • H5前端开发学习笔记——0x15清除浮动

    清除浮动 课时130 浮动元素高度问题(掌握) 课时131 清除浮动方式一(理解) 课时132 清除浮动方式二(理...

  • css清除浮动

    前端开发中浮动处处可见,本文探讨浮动的成因以及如何更加有效的清除浮动。 1、浮动与清除浮动 2、清除浮动 基本cs...

  • CSS清除浮动三种方式

    清除浮动 当父盒子没有定义高度,嵌套的盒子浮动之后,下边的元素发生位置错误。 清除浮动不是不用浮动,清除浮动产生的...

  • 布局浮动的问题

    浮动的问题 什么是浮动?浮动(float)的副作用清除浮动两种清除浮动的办法如下:

网友评论

      本文标题:2018-06-10 清除浮动

      本文链接:https://www.haomeiwen.com/subject/xiuqeftx.html