您现在的位置是:css如何清除一分赛车投注网站浮动clear与float【北京PK10投注】少花钱中大奖_PK10开奖直播_PK拾技巧 >>正文
css如何清除一分赛车投注网站浮动clear与float【北京PK10投注】少花钱中大奖_PK10开奖直播_PK拾技巧
长枕大衾网3人已围观
简介一:空标签清浮动(如下代码)<!doctype html><html><head><meta charset="utf-8"><...
一:空标签清浮动(如下代码)
<!doctype html><html><head><meta charset="utf-8"><title>MAOLAI博客</title><link rel="stylesheet" href="reset.css"><style>.main div{float:left;width:300px;height:300px;margin-right:20px;background:#966;}.footer{width:620px;height:100px;background:red;}.clear{clear:both;height:0;}</style></head><body><div class="wrap"><div class="main"><div>个人博客</div><div>个人网站</div><p class="clear"></p></div><div class="footer"></div></div></body></html>
注释:上面用p标签进行空标签清浮动,但是有时希望内容能够撑开高度(比如内容不固定的时候)。
六:父元素设置display:table
<!doctype html><html><head><meta charset="utf-8"><title>MAOLAI博客</title><link rel="stylesheet" href="reset.css"><style>.main{display:table;}.main div{float:left;width:300px;height:300px;margin-right:20px;background:#966;}.footer{width:620px;height:100px;background:red;}</style></head><body><div class="wrap"><div class="main"><div>个人博客</div><div>个人网站</div></div><div class="footer"></div></div></body></html>
七:after 伪元素(不是伪类)
<!doctype html><html><head><meta charset="utf-8"><title>MAOLAI博客</title><link rel="stylesheet" href="reset.css"><style>.main div{float:left;width:300px;height:300px;margin-right:20px;background:#966;}.footer{width:620px;height:100px;background:red;}.clearfix:after{clear:both;display:block;height:0;content:"200B";}.clearfix{*zoom:1;}</style></head><body><div class="wrap"><div class="main clearfix"><div>个人博客</div><div>个人网站</div></div><div class="footer"></div></div></body></html>
注释:reset.css文件里面已经写好了after伪元素清浮动,但是一旦浮动,当然可以用别的标签;如果用行元素的话需要进行转化为块,浮动会对文档产生影响,如何进行选择清除浮动了?以下是清浮动的具体代码实现,父级div就相当于没有了内容(上面的例子中类名为main的高度为0了)。具体来看看会对文档产生什么影响?
清除浮动后的效果:
未清除浮动后的效果:
实例代码(未清除浮动):
<!doctype html><html><head><meta charset="utf-8"><title>MAOLAI博客</title><link rel="stylesheet" href="reset.css"><style>.main div{float:left;width:300px;height:300px;margin-right:20px;background:#966;}.footer{width:620px;height:100px;background:red;}</style></head><body><div class="wrap"><div class="main"><div>个人博客</div><div>个人网站</div></div><div class="footer"></div></div></body></html
解析:页面开发的时候可以为父级标签添加固定高度,它们是能够
二:br标签清除浮动(如下代码)
<!doctype html><html><head><meta charset="utf-8"><title>MAOLAI博客</title><link rel="stylesheet" href="reset.css"><style>.main div{float:left;width:300px;height:300px;margin-right:20px;background:#966;}.footer{width:620px;height:100px;background:red;}</style></head><body><div class="wrap"><div class="main"><div>个人博客</div><div>个人网站</div><!--br标签自带的属性--><br clear="all">一分赛车投注网站;</div><div class="footer"></div></div></body></html>
三:父元素设置overflow:hidden (如下代码)
<!doctype html> <html> <head><meta charset="utf-8"> <title>MAOLAI博客</title> <link rel="stylesheet" href="reset.css"> <style> .main{over【北京PK10投注】少花钱中大奖_PK10开奖直播_PK拾技巧flow:hidden;} .main div{float:left;width:300px;height:300px;margin-right:20px;background:#966;} .footer{width:620px;height:100px;background:red;} </style> </head> <body> <div class="wrap"> <div class="main"> <div>个人博客</div> <div>个人网站</div> </div> <div class="footer"></div> </div> </body> </html>
四:父元素设置overflow:auto (如下代码)
<!doctype html><html><head><meta charset="utf-8"><title>MAOLAI博客</title><link rel="stylesheet" href="reset.css"><style>.main{overflow:auto;}.main div{float:left;width:300px;height:300px;margin-right:20px;background:#966;}.footer{width:620px;height:100px;background:red;}</style></head><body><div class="wrap"><div class="main"><div>个人博客</div><div>个人网站</div></div><div class="footer"></div></div></body></html>
五:父元素浮动
<!doctype html><html><head><meta charset="utf-8"><title>MAOLAI博客</title><link rel="stylesheet" href="reset.css"><style>.main{float:left;}.main div{float:left;width:300px;height:300px;margin-right:20px;background:#966;}.footer{width:620px;height:100px;background:red;}</style></head><body><div class="wrap"><div class="main"><div>个人博客</div><div>个人网站</div></div><div class="footer"></div></div></body></html>
效果:
注释:使得与父元素相邻的元素的布局会受到影响(影响到了类名为footer的元素)。
大家都知道,块元素就没有必要转化啦。此时需要进行清除浮动对布局造成的一系列影响,(不要误解成把浮动清除了,
清除浮动有很多种,对于不浮动的元素来说,
Tags:
相关文章
php7.4帝国CMS报错Deprecated: Function get
css如何清除一分赛车投注网站浮动clear与float【北京PK10投注】少花钱中大奖_PK10开奖直播_PK拾技巧把网站服务器运行环境php5.6切换成php7.4版本后,帝国cms出现Deprecated: Function get_magic_quotes_gpc() is deprecated in D:\...
阅读更多
创意的分割线404错误页面代码
css如何清除一分赛车投注网站浮动clear与float【北京PK10投注】少花钱中大奖_PK10开奖直播_PK拾技巧创意的分割线404错误页面模板,卡通创意的波浪分割线404错误提示页面,人物提示404页面代码。...
阅读更多
dedecms漂亮美女图片网站模板v1.1
css如何清除一分赛车投注网站浮动clear与float【北京PK10投注】少花钱中大奖_PK10开奖直播_PK拾技巧本dedecms图片模板一套图集模型美图图片网模板(仿6188美图网),织梦模板由网上网友分享下载的,安装测试过程序遇到Fatal error: Call to a member function G...
阅读更多