div标签清除float浮动样式方法
2017-08-27 00:16
525 查看
方法一、
这个方法来源于positioniseverything ,通过after伪类实现,完全兼容当前主流浏览器。
方法二、
还有一个无敌的清除浮动的样式,这个是通过独立的代码来清除的。
可以通过在页面div中添加clear样式来清除页面中的浮动。
方法三、
实际项目中常用如下代码:
使用方法如下:
这个方法来源于positioniseverything ,通过after伪类实现,完全兼容当前主流浏览器。
1 <style type="text/css"> 2 .clearfix:after { 3 content: "."; 4 display: block; 5 height: 0; 6 clear: both; 7 visibility: hidden; 8 } 9 .clearfix {display: inline-block;} /* for IE/Mac */ 10 </style> 11 <!-- main stylesheet ends, CC with new stylesheet below... --> 12 <!--[if IE]> 13 <style type="text/css"> 14 .clearfix { 15 zoom: 1; /* triggers hasLayout */ 16 display: block; /* resets display for IE/Win */ 17 } 18 /* Only IE can see inside the conditional comment 19 and read this CSS rule. Don't ever use a normal HTML 20 comment inside the CC or it will close prematurely. */ 21 </style> 22 <![endif]-->
方法二、
还有一个无敌的清除浮动的样式,这个是通过独立的代码来清除的。
可以通过在页面div中添加clear样式来清除页面中的浮动。
1 <div class=”clear”> 2 </div> 3 或 4 <span class=”clear”> 5 </span>
方法三、
实际项目中常用如下代码:
使用方法如下:
相关文章推荐
- DIV设置浮动float以后下一个DIV要换行的方法
- DIV+CSS中清除浮动的7种方法分析
- css清除浮动float的三种方法总结,为什么清浮动?浮动会有那些影响?
- div添加背景图时候与清除浮动样式冲突
- 清除div下面的所有标签的方法
- CSS清除float浮动的常用几种方法
- div清除浮动css样式代码分享(4种方法)
- 关于css中float的用法整理及清除浮动方法。
- 彻底理解浮动float CSS浮动详解 清除浮动的方法
- css清除浮动float的三种方法总结,为什么清浮动?浮动会有那些影响?一起来$('.float')
- css清除浮动float的三种方法总结,为什么清浮动?浮动会有那些影响?一起来$('.float')
- 彻底理解浮动float CSS浮动详解 清除浮动的方法
- CSS清除float浮动_div+css简单了解
- html在一行内横向排列并排同行同时显示两个多个div盒子的方法(CSS浮动清除float-clear/inline)/办法
- css清除浮动float的三种方法总结,为什么清浮动?浮动会有哪些影响?
- 清除float浮动的几种方法
- CSS之浮动布局(float,浮动原理,清除/闭合浮动方法)
- css清除浮动float的三种方法总结
- css清除浮动float的三种方法总结,为什么清浮动?浮动会有那些影响?
- DIV设置浮动float以后下一个DIV要换行的方法