css如九游互娱软件下载何清除闲娱游戏浮动clear与float
一:空标签清浮动(如下代码)
<!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标签进行空标签清浮动,具体来看看会对文档产生什么影响?
清除浮动后的效果:
未清除浮动后的效果:
实例代码(未清除浮动):
<!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{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的元素)。不是同一概念)。(不要误解成把浮动清除了,直接调用即可。对于不浮动的元素来说,
清除浮动有很多种,但是有时希望内容能够撑开高度(比如内容不固定的时候)。元素就
六:父元素设置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伪元素清浮动,元素脱离文档流,
大家都知道,
-
上一篇
-
下一篇
- 最近发表
-
- dedecms织梦仿站工具软件下载
- dedecms织梦5.7仿站视频教程(中级下部)
- 个人网站是否需要做https协议
- WordPress文章历史修订版本与自动草稿保存问题
- jquery图片无缝滚动代码T字形无缝滚动效果
- These Crypto Assets Dumped the Most as the Total Market Cap Shed Over $200B (Weekend Watch)
- JavaScript对象和数组(Object类型与Array类型)
- UNI Slumps 17% Following SEC Developments, BTC, ETH, DOGE, TON on the Rise (Market Watch)
- 通过PhpMyAdmin找回wordpress登录密码
- jquery css3图片翻转3D动画切换特效代码
- 随机阅读
-
- wordpress XIU主题(阿里百秀)小清新cms模板V5.6
- 创意的404错误页面模板报错设计
- 电脑本地搭建dedecms/帝国cms个人网站教程
- WHOIS域名信息查询php源码
- 小米米家推出折叠偏光近视太阳镜,轻巧便携又护眼,仅售199元!
- WordPress多功能免费主题Git(乐趣公园)下载
- html5响应式时间轴页面模板大全
- 圣诞节幽灵404页面代码
- WordPress主题wpdx响应式CMS/Blog双布局v3.6
- 分类目录缩略图自动截图/生成api有哪些
- WordPress外链图片插件Featured Image from URL
- 个人博客主页如何做网站优化
- 23亿!武汉青山区(化工区)北湖绿城EOD项目实施主体征求意见
- html5+css3制作音乐列表播放器源码
- 卡通男女电筒404错误页面动画
- Google搜索引擎搜索查询表现形式
- 黑色清爽大气wordpress博客主题,html静态模板
- 23亿!武汉青山区(化工区)北湖绿城EOD项目实施主体征求意见
- wordpress网站隐藏内容付费阅读/下载插件foxpay
- jQuery粉色个性侧边悬浮音乐播放器插件
- 搜索
-
- 友情链接
-