CSS clear both清除浮动
来源:互联网 发布:风能模拟软件 编辑:程序博客网 时间:2024/04/24 21:17
我们知道有时使用了css float浮动会产生css浮动,这个时候就需要清理清除浮动,我们就用clear样式属性即可实现。
接下来我们来认识与学习css clear知识与用法。
一、clear语法与结构 - TOP
1、clear语法:
clear : none | left|right| both
2、clear参数值说明:
none : 允许两边都可以有浮动对象
both : 不允许有浮动对象
left : 不允许左边有浮动对象
right : 不允许右边有浮动对象
3、clear解释:
该属性的值指出了不允许有浮动对象的边情况,又对象左边不允许有浮动、右边不允许有浮动、不允许有浮动对象。
4、css结构
div{clear:left}
div{clear:right}
div{clear:both}
二、div clear常用地方 - TOP
我们常常用于使用了float css样式后产生浮动,最常用是使用clear:both清除浮动。比如一个大对象内有2个小对象使用了css float样式为了避免产生浮动,大对象背景或边框不能正确显示,这个时候我们就需要clear:both清除浮动。
三、css+div案例 - TOP
DIVCSS5案例说明:这里设置一个css宽度(css width)为500px;盒子,css边框(css border)为红色,css背景(css background)为黑色、css padding为10px盒子,里面包裹着2个小盒子,一个css 浮动靠右(float:right)、一个css float靠左(float:left),两者边框为白色,背景颜色为灰色,宽度为200px,css高度(css height)为150px。这样我们来观察案例效果,看浮动产生并使用clear清除浮动。
1、案例css代码:
- .divcss5{width:500px;background:#000;border:1px solid #F00;padding:10px}
- .divcss5_left,.divcss5_right{
- border:1px solid #FFF;background:#999;width:200px;height:150px
- }
- /* css注释: 这里为了截图分别,对css代码换行 */
- .divcss5_left{ float:left}/* css注释: 设置浮动靠左 */
- .divcss5_right{ float:right}/* css注释:设置浮动靠右 */
2、案例html代码片段:
- <div class="divcss5">
- <div class="divcss5_left">float left盒子</div>
- <div class="divcss5_right">float right盒子</div>
- </div>
3、案例效果截图
css div浮动产生与清除案例截图
这个时候需要clear来清除浮动,让css命名为“divcss5”盒子撑开。
4、清除浮动方法
我们在css代码中加入CSS代码:
- .clear{ clear:both}
Html代码中“.divcss5”盒子</div>结束标签前加入代码:
- <div class="clear"></div>
最终使用div css clear清除浮动后应用用法案例截图
Clear使用用法案例截图
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml"><head><title>css省略号text-overflow超出溢出显示省略号</title><meta http-equiv="Content-type" content="text/html;charset=utf-8"/><style type="text/css">.divcss5{width: 500px;background: #000;border: 1px solid #f00;padding: 10px;}.divcss5_left,.divcss5_right{border:1px solid #fff;background: #999;width:200px;height:150px;}.divcss5_left{float:left;}.divcss5_right{float:right;}.clear{clear:both;}</style></head><body><div class="divcss5"><div class="divcss5_left">flot left 盒子</div><div class="divcss5_right">float right 盒子</div><div class="clear"></div></div></body></html>
- CSS clear both清除浮动
- CSS clear both清除浮动
- CSS clear both清除浮动
- DIV+CSS clear both清除产生浮动
- css Clear:both 清除float浮动
- DIV+CSS clear both清除产生浮动
- CSS 浮动(float:left),清除浮动(clear:both)
- [HTML]DIV+CSS clear both清除产生浮动
- css clear 清除浮动
- 清除浮动clear:both的应用详解
- 清除浮动“clear:both;”的应用
- 巧妙运用清除浮动clear:both
- 清除浮动 clear:both的原理
- CSS清除浮动_清除float浮——详解overflow:hidden 与clear:both属性
- CSS清除浮动常用方法小结 CSS clear both {overflow:auto;zoom:1;}
- 【转载】CSS clear 清除浮动
- css清除浮动 clear float
- CSS之清除浮动clear
- 适配器模式
- linux service命令常见使用方法
- flowers
- 基于Linux下 Qt 对于Opengl中glu开头函数不能使用的研究
- C++中依赖受限名称定义编译无法通过的问题
- CSS clear both清除浮动
- Redis测试_推荐pipeline
- 【存储管理】请求淘汰换页算法最优淘汰算法(optimal replacement algorithm,OPT)
- 来谈谈C++ 位运算 & | << >> ^ ~ %
- OutputStream和Writer
- 关于QQ通讯录的应用及vcf文件导入手机的乱码问题
- 谁考了第k名:Wrong Answer
- mongodb安全问题
- 乐队设备---均衡器的学习和使用