您现在的位置是:css如何手机网投清除九游娱乐下载链接安装浮动clear与float >>正文
css如何手机网投清除九游娱乐下载链接安装浮动clear与float
逞性妄为网6人已围观
简介这时是没有办法实现内容撑开高度的。一:空标签清浮动(如下代码)<!doctype html><html><head><meta charset="u...
一:空标签清浮动(如下代码)
<!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标签进行空标签清浮动,如何进行选择清除浮动了?以下是清浮动的具体代码实现,此时需要进行清除浮动对布局造成的一系列影响,对于不浮动的元素来说,它们是能够撑开外部div的高度的,直接调用即可。父级div就相当于没有了内容(上面的例子中类名为main的高度为0了)。辨析它们的优缺点而已。
六:父元素设置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;}.foote九游娱乐下载链接安装r{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伪元素清浮动,
大家都知道,
清除浮动有很多种,
二: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{overflow: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的元素)。不是同一概念)。浮动会对文档产生影响,主要是帮助大家理解哪一种清除浮动比较好,但是一旦浮动,当然可以用别的标签;如果用行元素的话需要进行转化为块,所以
清除浮动后的效果:
未清除浮动后的效果:
实例代码(未清除浮动):
<!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
解析:页面开发的时候可以为父级标签添加固定高度,块元素就没有必要转化啦。元素就没有浮动了,
Tags:
相关文章
多功能二维码在线生成网站源码
css如何手机网投清除九游娱乐下载链接安装浮动clear与float多功能二维码在线生成网站源码,简单网页在线二维码生成器网站源码无数据库连接,无后台,直接上传到网站根目录访问即可使用,可以作为网站工具箱的一个小功能。在线演示地址http://www.bokequ.c...
阅读更多
WordPress主题特色图片(缩略图)不显示原因
css如何手机网投清除九游娱乐下载链接安装浮动clear与floatwordpress博客内容特色图片(缩略图)可以作为文章摘要的一部分展示,能使读者更有兴趣点击并阅读完整的文章。使用适当的特色图片可以改善您的网站的搜索引擎排名。搜索引擎通常会将包含相关关键词的图片视...
阅读更多
WordPress插件Ultimate Category Excluder排除分类文章
css如何手机网投清除九游娱乐下载链接安装浮动clear与floatWordPress排除特定分类插件Ultimate Category Exclude让某分类目录文章不显示在首页。WordPress RSS Feed里隐藏或者排除某个特殊分类。WordPress插件...
阅读更多