首 页
网络学院
视频教程
资源下载
HOT
实例教程
图文教程
专题中心
学习社区
繁體中文
当前位置:
首页
>
图文教程
>
网页制作
>
CSS样式表
> css 完美清除浮动的两种解决方案
CSS样式表
CSS Sprite的一些最佳实践方法
绝对定位(absolute)和浮动定位(float)分析
IE 选择符的4095限制
CSS IE6奇数宽度或高度的bug
CSS Border属性制作小三角
清理CSS样式的几个有用工具
IE7 position:relative的问题
CSS 网页布局中易犯的10个小错误小结
纯CSS搞定按钮、链接点击时的虚线
CSS经典技巧十则
CSS超级技巧大放送合集
漂亮的表格
首届世界CSS设计大赛结果揭晓
HTML表单元素覆盖样式元素问题及其补救之道
网页美工制作规范
top、clientTop、scrollTop、offsetTop
双表法调用样式表
典型的三行二列居中高度自适应布局
用!important解决IE和Mozilla的布局差别
CSS hack浏览器兼容一览表
No.
«
‹
80
81
82
83
›
»
技术文章搜索
关键字
CSS样式表 中的 css 完美清除浮动的两种解决方案
出处:
互联网
整理:
软晨网(RuanChen.com)
发布:
2009-09-11
浏览: 116 ::
收藏到网摘: n/a
纯css 鼠标移上查看大图的效果
css 透明度的设置兼容所有浏览器
浮动一直是我们编写网页最常用的方法,但是也是最不听话的,一不小心会乱跑,虽然有万能的float闭合div多写一个可以解决掉,但是为了清除浮动而多出来一个空的div实在看着不爽,这里我在网上找到了两种解决的办法,相信很多朋友已经在用了,不过还是列出来,以备后用。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1- transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>完美清除浮动的两种解决方案</title> <style type="text/css"> ul{ list-style:none; height:auto; margin:0; padding:0; background-color:#436973; } li{ float:left; width:80px; height:120px; background-color:#83B1DF; } .demo{ clear:both; border:1px solid #FF00FF; margin-bottom:5px; } .overflow{ height:auto; _height:200px; min-height:200px; overflow:auto; zoom:1; _overflow:visible; } .clear:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }/*for w3c*/ .clear { zoom:1; }/*for IE*/ </style> </head> <body> <div class="demo"> <ul class="overflow"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> <li>7</li> <li>8</li> <li>9</li> </ul> </div> <div class="demo"> <ul class="clear"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> <li>6</li> <li>7</li> <li>8</li> <li>9</li> </ul> </div> </body> </html>
提示:您可以先修改部分代码再运行
纯css 鼠标移上查看大图的效果
css 透明度的设置兼容所有浏览器
评论 (0)
All
登陆
还没注册?