美文网首页
清除浮动

清除浮动

作者: 芒果加奶 | 来源:发表于2017-12-19 12:55 被阅读0次

1.父类div定义height

2.结尾处空div标签 clear:both

3.父类div上加上overflow:hidden

4.使用伪类方法

.div1{background:#000080;border:1px solid red;} 
.div2{background:#800080;border:1px solid red;height:100px;margin-top:10px} 
.left{float:left;width:20%;height:200px;background:#DDD} 
.right{float:right;width:30%;height:80px;background:#DDD} 
/*清除浮动代码 三种*/ 
/*.div1{overflow: hidden;}*/
/*.div1{height: 300px;}*/
/*.clearfloat:after{display:block;clear:both;content:"";visibility:hidden;height:0} 
.clearfloat{zoom:1}*/
<div class="div1 clearfloat"> 
    <div class="left">Left</div> 
    <div class="right">Right</div> 
</div> 
<div class="div2">div2</div> 

相关文章

  • 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)的副作用清除浮动两种清除浮动的办法如下:

  • 清除浮动

    一、清除浮动 or 闭合浮动 ? 清除浮动:清除对应的单词是 clear,对应CSS中的属性是 clear:lef...

网友评论

      本文标题:清除浮动

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