共计 11555 个字符,预计需要花费 29 分钟才能阅读完成。
一、前言
CSS clear both 革除产生浮动,应用了 css float 浮动会产生 css 浮动,这个时候就须要清理革除浮动,就用 clear 款式属性即可实现。
二、clear 语法与构造
1. clear 语法
clear : none | left|right| both
2. clear 参数值阐明
属性
形容
none
容许两边都能够有浮动对象
bot
不容许有浮动对象
left
不容许右边有浮动对象
right
不容许左边有浮动对象
3. clear 解释
该属性的值指出了不容许有浮动对象的边状况,对象右边不容许有浮动、左边不容许有浮动、不容许有浮动对象。
4. css 构造
div {clear: left}/r[url]https://book.douban.com/doulist/136178774/[/url]
[url]https://m.douban.com/doulist/136178685/[/url]
[url]https://book.douban.com/doulist/136178683/[/url]
[url]https://book.douban.com/doulist/136178719/[/url]
[url]https://m.douban.com/doulist/136178758/[/url]
[url]https://movie.douban.com/doulist/136178672/[/url]
[url]https://m.douban.com/doulist/136178756/[/url]
[url]https://www.douban.com/doulist/136178706/[/url]
[url]https://m.douban.com/doulist/136178712/[/url]
[url]https://m.douban.com/doulist/136178658/[/url]
[url]https://book.douban.com/doulist/136178672/[/url]
[url]https://www.douban.com/doulist/136178680/[/url]
[url]https://www.douban.com/doulist/136178648/[/url]
[url]https://book.douban.com/doulist/136178739/[/url]
[url]https://movie.douban.com/doulist/136178733/[/url]
[url]https://www.douban.com/doulist/136178642/[/url]
[url]https://www.douban.com/doulist/136178766/[/url]
[url]https://www.douban.com/doulist/136178768/[/url]
[url]https://movie.douban.com/doulist/136178668/[/url]
[url]https://movie.douban.com/doulist/136178660/[/url]
[url]https://m.douban.com/doulist/136178731/[/url]
[url]https://www.douban.com/doulist/136178664/[/url]
[url]https://book.douban.com/doulist/136178776/[/url]
[url]https://book.douban.com/doulist/136178744/[/url]
[url]https://www.douban.com/doulist/136178771/[/url]
[url]https://book.douban.com/doulist/136178731/[/url]
[url]https://www.douban.com/doulist/136178712/[/url]
[url]https://m.douban.com/doulist/136178647/[/url]
[url]https://book.douban.com/doulist/136178699/[/url]
[url]https://book.douban.com/doulist/136178680/[/url]
[url]https://book.douban.com/doulist/136178646/[/url]
[url]https://movie.douban.com/doulist/136178683/[/url]
[url]https://book.douban.com/doulist/136178723/[/url]
[url]https://m.douban.com/doulist/136178691/[/url]
[url]https://book.douban.com/doulist/136178758/[/url]
[url]https://m.douban.com/doulist/136178683/[/url]
[url]https://movie.douban.com/doulist/136178700/[/url]
[url]https://www.douban.com/doulist/136178763/[/url]
[url]https://www.douban.com/doulist/136178702/[/url]
[url]https://www.douban.com/doulist/136178751/[/url]
[url]https://m.douban.com/doulist/136178739/[/url]
[url]https://book.douban.com/doulist/136178707/[/url]
[url]https://movie.douban.com/doulist/136178761/[/url]
[url]https://movie.douban.com/doulist/136178699/[/url]
[url]https://book.douban.com/doulist/136178647/[/url]
[url]https://book.douban.com/doulist/136178710/[/url]
[url]https://www.douban.com/doulist/136178699/[/url]
[url]https://www.douban.com/doulist/136178731/[/url]
[url]https://m.douban.com/doulist/136178751/[/url]
[url]https://www.douban.com/doulist/136178677/[/url]
[url]https://www.douban.com/doulist/136178710/[/url]
[url]https://book.douban.com/doulist/136178660/[/url]
[url]https://www.douban.com/doulist/136178634/[/url]
[url]https://www.douban.com/doulist/136178658/[/url]
[url]https://m.douban.com/doulist/136178639/[/url]
[url]https://m.douban.com/doulist/136178646/[/url]
[url]https://movie.douban.com/doulist/136178719/[/url]
[url]https://movie.douban.com/doulist/136178723/[/url]
[url]https://movie.douban.com/doulist/136178691/[/url]
[url]https://book.douban.com/doulist/136178668/[/url]
[url]https://book.douban.com/doulist/136178648/[/url]
[url]https://m.douban.com/doulist/136178642/[/url]
[url]https://www.douban.com/doulist/136178761/[/url]
[url]https://movie.douban.com/doulist/136178677/[/url]
[url]https://www.douban.com/doulist/136178759/[/url]
[url]https://m.douban.com/doulist/136178733/[/url]
[url]https://www.douban.com/doulist/136178655/[/url]
[url]https://movie.douban.com/doulist/136178744/[/url]
[url]https://book.douban.com/doulist/136178685/[/url]
[url]https://www.douban.com/doulist/136178646/[/url]
[url]https://book.douban.com/doulist/136178763/[/url]
[url]https://m.douban.com/doulist/136178748/[/url]
[url]https://movie.douban.com/doulist/136178774/[/url]
[url]https://m.douban.com/doulist/136178664/[/url]
[url]https://movie.douban.com/doulist/136178646/[/url]
[url]https://movie.douban.com/doulist/136178776/[/url]
[url]https://m.douban.com/doulist/136178776/[/url]
[url]https://book.douban.com/doulist/136178706/[/url]
[url]https://m.douban.com/doulist/136178766/[/url]
[url]https://movie.douban.com/doulist/136178712/[/url]
[url]https://movie.douban.com/doulist/136178746/[/url]
[url]https://m.douban.com/doulist/136178759/[/url]
[url]https://movie.douban.com/doulist/136178771/[/url]
[url]https://www.douban.com/doulist/136178733/[/url]
[url]https://m.douban.com/doulist/136178700/[/url]
[url]https://m.douban.com/doulist/136178675/[/url]
[url]https://book.douban.com/doulist/136178677/[/url]
[url]https://movie.douban.com/doulist/136178751/[/url]
[url]https://book.douban.com/doulist/136178761/[/url]
[url]https://movie.douban.com/doulist/136178639/[/url]
[url]https://www.douban.com/doulist/136178746/[/url]
[url]https://movie.douban.com/doulist/136178636/[/url]
[url]https://movie.douban.com/doulist/136178634/[/url]
[url]https://book.douban.com/doulist/136178639/[/url]
[url]https://www.douban.com/doulist/136178723/[/url]
[url]https://book.douban.com/doulist/136178756/[/url]
[url]https://m.douban.com/doulist/136178705/[/url]
[url]https://movie.douban.com/doulist/136178756/[/url]
[url]https://www.douban.com/doulist/136178776/[/url]
[url]https://www.douban.com/doulist/136178715/[/url]
[url]https://book.douban.com/doulist/136178717/[/url]
[url]https://www.douban.com/doulist/136178756/[/url]
[url]https://book.douban.com/doulist/136178746/[/url]
[url]https://www.douban.com/doulist/136178668/[/url]
[url]https://www.douban.com/doulist/136178744/[/url]
[url]https://movie.douban.com/doulist/136178655/[/url]
[url]https://m.douban.com/doulist/136178706/[/url]
[url]https://book.douban.com/doulist/136178766/[/url]
[url]https://m.douban.com/doulist/136178677/[/url]
[url]https://book.douban.com/doulist/136178664/[/url]
[url]https://book.douban.com/doulist/136178658/[/url]
[url]https://m.douban.com/doulist/136178648/[/url]
[url]https://m.douban.com/doulist/136178768/[/url]
[url]https://www.douban.com/doulist/136178647/[/url]
[url]https://m.douban.com/doulist/136178710/[/url]
[url]https://m.douban.com/doulist/136178680/[/url]
[url]https://m.douban.com/doulist/136178672/[/url]
[url]https://m.douban.com/doulist/136178717/[/url]
[url]https://www.douban.com/doulist/136178660/[/url]
[url]https://m.douban.com/doulist/136178744/[/url]
[url]https://book.douban.com/doulist/136178771/[/url]
[url]https://book.douban.com/doulist/136178759/[/url]
[url]https://www.douban.com/doulist/136178675/[/url]
[url]https://www.douban.com/doulist/136178691/[/url]
[url]https://movie.douban.com/doulist/136178642/[/url]
[url]https://movie.douban.com/doulist/136178687/[/url]
[url]https://book.douban.com/doulist/136178748/[/url]
[url]https://movie.douban.com/doulist/136178710/[/url]
[url]https://m.douban.com/doulist/136178660/[/url]
[url]https://m.douban.com/doulist/136178719/[/url]
[url]https://movie.douban.com/doulist/136178766/[/url]
[url]https://book.douban.com/doulist/136178705/[/url]
[url]https://book.douban.com/doulist/136178715/[/url]
[url]https://www.douban.com/doulist/136178707/[/url]
[url]https://movie.douban.com/doulist/136178763/[/url]
[url]https://movie.douban.com/doulist/136178706/[/url]
[url]https://book.douban.com/doulist/136178687/[/url]
[url]https://book.douban.com/doulist/136178702/[/url]
[url]https://book.douban.com/doulist/136178712/[/url]
[url]https://m.douban.com/doulist/136178702/[/url]
[url]https://book.douban.com/doulist/136178675/[/url]
[url]https://m.douban.com/doulist/136178634/[/url]
[url]https://www.douban.com/doulist/136178705/[/url]
[url]https://m.douban.com/doulist/136178636/[/url]
[url]https://www.douban.com/doulist/136178758/[/url]
[url]https://movie.douban.com/doulist/136178685/[/url]
[url]https://m.douban.com/doulist/136178723/[/url]
[url]https://www.douban.com/doulist/136178672/[/url]
[url]https://book.douban.com/doulist/136178655/[/url]
[url]https://book.douban.com/doulist/136178700/[/url]
[url]https://www.douban.com/doulist/136178748/[/url]
[url]https://m.douban.com/doulist/136178761/[/url]
[url]https://www.douban.com/doulist/136178639/[/url]
[url]https://m.douban.com/doulist/136178668/[/url]
[url]https://www.douban.com/doulist/136178685/[/url]
[url]https://movie.douban.com/doulist/136178731/[/url]
[url]https://movie.douban.com/doulist/136178768/[/url]
[url]https://m.douban.com/doulist/136178655/[/url]
[url]https://movie.douban.com/doulist/136178707/[/url]
[url]https://m.douban.com/doulist/136178771/[/url]
[url]https://www.douban.com/doulist/136178683/[/url]
[url]https://book.douban.com/doulist/136178768/[/url]
[url]https://movie.douban.com/doulist/136178680/[/url]
[url]https://www.douban.com/doulist/136178739/[/url]
[url]https://book.douban.com/doulist/136178751/[/url]
[url]https://book.douban.com/doulist/136178733/[/url]
[url]https://movie.douban.com/doulist/136178748/[/url]
[url]https://m.douban.com/doulist/136178715/[/url]
[url]https://www.douban.com/doulist/136178636/[/url]
[url]https://www.douban.com/doulist/136178717/[/url]
[url]https://book.douban.com/doulist/136178634/[/url]
[url]https://movie.douban.com/doulist/136178675/[/url]
[url]https://m.douban.com/doulist/136178746/[/url]
[url]https://movie.douban.com/doulist/136178658/[/url]
[url]https://book.douban.com/doulist/136178642/[/url]
[url]https://m.douban.com/doulist/136178763/[/url]
[url]https://movie.douban.com/doulist/136178715/[/url]
[url]https://movie.douban.com/doulist/136178717/[/url]
[url]https://movie.douban.com/doulist/136178705/[/url]
[url]https://movie.douban.com/doulist/136178739/[/url]
[url]https://movie.douban.com/doulist/136178647/[/url]
[url]https://movie.douban.com/doulist/136178664/[/url]
[url]https://m.douban.com/doulist/136178707/[/url]
[url]https://www.douban.com/doulist/136178687/[/url]
[url]https://book.douban.com/doulist/136178636/[/url]
[url]https://m.douban.com/doulist/136178699/[/url]
[url]https://movie.douban.com/doulist/136178648/[/url]
[url]https://www.douban.com/doulist/136178700/[/url]
[url]https://movie.douban.com/doulist/136178759/[/url]
[url]https://m.douban.com/doulist/136178774/[/url]
[url]https://movie.douban.com/doulist/136178702/[/url]
[url]https://m.douban.com/doulist/136178687/[/url]
[url]https://www.douban.com/doulist/136178719/[/url]
[url]https://movie.douban.com/doulist/136178758/[/url]
[url]https://book.douban.com/doulist/136178691/[/url]
[url]https://www.douban.com/doulist/136178774/[/url]
/h
div {clear: right}
div {clear: both}
三、div clear 罕用的状况
最罕用是应用 clear:both 革除浮动。
比方一个大对象内有 2 个小对象应用了 css float 款式为了防止产生浮动,大对象背景或边框不能正确显示,这个时候就须要 clear:both 革除浮动。
四、案例
1. 案例阐明
设置一个 css 宽度(css width)为 500px; 盒子(div),css 边框(css border)为红色,css 背景(css background)为彩色、css padding 为 10px 盒子,外面包裹着 2 个小盒子,一个 css 浮动靠右(float:right)、一个 css float 靠左(float:left),两者边框为红色,背景色彩为灰色,宽度为 200px,css 高度、css height 为 150px。
这样来察看案例成果,看浮动产生并应用 clear 革除浮动。
css 代码:
.div css5 {
width: 500px;
background: #000;
border: 1px solid #F00;
padding: 10px
}
.div css5_left,
.div css5_right {
border: 1px solid #FFF;
background: #999;
width: 200px;
height: 150px
}
/* css 正文:这里为了截图别离,对 css 代码换行 */
.div css5_left {float: left}
/* css 正文:设置浮动靠左 */
.div css5_right {float: right}
/* css 正文:设置浮动靠右 */
html 代码片:
<div class="div css5">
<div class="div css5_left">float left 盒子 </div >
<div class="div css5_right">float right 盒子 </div >
</div>
案例成果截图
2. 革除浮动办法
在 css 代码中退出 CSS 代码:
.clear{clear:both}
Html 代码中“.div css5”盒子 * 完结标签前退出代码:
<div class="clear"></div>
革除浮动效果图:
五、总结
本文基于 Html 根底,介绍了在理论开发中,能够应用 clear 能够革除 float 产生的浮动。在应用 clear 款式对象退出地位,只须要在此对象 div 标签完结前,退出即可革除外部小盒子产生浮动。而个别罕用 clear:both 来革除浮动。采纳代码加截图的形式,心愿可能更好的帮忙你学习。