您现在的位置是:css如何游聚游戏平台官网清除网投庄闲下载浮动clear与float >>正文
css如何游聚游戏平台官网清除网投庄闲下载浮动clear与float
耕当问奴网8458人已围观
简介六:父元素设置display:table<!doctype html><html><head><meta charset="utf-8"&...
六:父元素设置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;}</style></head><body><div class="wrap"><div class="main"><div>个人博客</div><div>个人网站</div></div><div class="footer"></div></div></body></html
解析:页面开发的时候可以为父级标签添加固定高度,元素游聚游戏平台官网trong>网投庄闲下载就没有浮动了,它们是能够撑开外部div的高度的,块元素就没有必要转化啦。
大家都知道,直接调用即可。此时需要进行清除浮动对布局造成的一系列影响,
一:空标签清浮动(如下代码)
<!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标签进行空标签清浮动,
Tags:
上一篇:个人博客网站日志404状态码分析
相关文章
SEO网站优化之URL的写法
css如何游聚游戏平台官网清除网投庄闲下载浮动clear与float1、URL越短越好据了解,最长的网站URL好像是可以为一千个字母,只不过是互联网上的一些资料。相信真正这样去做的网站,可能很少。毕竟这不符合用户体验的要求,搜索引可能收录没什么问题,那么用户想记下这么...
阅读更多
CSS3变形效果transform
css如何游聚游戏平台官网清除网投庄闲下载浮动clear与float一、3D 变形简介元素的平移、旋转、缩放和倾斜等功能这些效果只是单纯在二维平面图上的,我们称之为 2D。那么其实CSS3也提供了三维立体的一些功能效果,并且目前较新的主流浏览器都比较支持,只不过比 2...
阅读更多
JavaScript对象和数组(Object类型与Array类型)
css如何游聚游戏平台官网清除网投庄闲下载浮动clear与float什么是对象,其实就是一种类型,即引用类型。而对象的值就是引用类型的实例。在ECMAScript 中引用类型是一种数据结构,用于将数据和功能组织在一起。它也常被称做为类,但 ECMAScript 中却没...
阅读更多