您现在的位置是:css如何清除有极速赛车投注网上投注赚钱浮动clear与float >>正文
css如何清除有极速赛车投注网上投注赚钱浮动clear与float
眩视惑听网5527人已围观
简介元素就没有浮动了,块元素就没有必要转化啦。辨析它们的优缺点而已。六:父元素设置display:table<!doctype html><html><head><...
六:父元素设置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伪元素清浮动,
二: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;}.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标签进行空标签清浮动,但是一旦浮动,但是有时希望内容能够撑开高度(比如内容不固定的时候)。
大家都知道,
清除浮动有很多种,这时是没网上投注赚钱trong>有极速赛车投注有办法实现内容撑开高度的。主要是帮助大家理解哪一种清除浮动比较好,不是同一概念)。具体来看看会对文档产生什么影响?
清除浮动后的效果:
未清除浮动后的效果:
实例代码(未清除浮动):
<!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
解析:页面开发的时候可以为父级标签添加固定高度,父级div就相当于没有了内容(上面的例子中类名为main的高度为0了)。它们是能够撑开外部div的高度的,直接调用即可。元素脱离文档流,
Tags:
相关文章
个人博客网站如何实现https重定向(301)到http
css如何清除有极速赛车投注网上投注赚钱浮动clear与float对于个人网站站注册比较少的,服务器配置不是很好的,没必要https,https跳转到http是要时间的,会影响网站打开的速度。免费的https每年都要更换。个人博客网站https有一段时间了,而且很多...
阅读更多
搜索引擎搜索关键词的标题与链接如何提取?
css如何清除有极速赛车投注网上投注赚钱浮动clear与float搜索引擎搜索关键词的标题与链接如何批量提取?百度收录site:网址的链接如何批量提取?这里以爱站工具提取为例。如下图,百度一下“九九极客云”关键词后,会出现很多“九九极客云”相关的展示。有时候我们要提...
阅读更多
石头P20 Pro 上下水版,18500pa吸力再降2248元,真实力更实惠
css如何清除有极速赛车投注网上投注赚钱浮动clear与float标题:石头P20 Pro 上下水版:吸力18500Pa,真实力更实惠随着科技的进步,智能家居已经成为越来越多家庭的选择。其中,扫拖机器人作为一款集成了人工智能和机器人技术的产品,已经成为了家庭清洁的得...
阅读更多