IE下LI元素产生间距的BUG(附解决方案) - CSS+DIV -

IE下LI元素产生间距的BUG(附解决方案)

时间:2010-01-28 10:40:10   来源:   评论:加载中...   点击:加载中...
不光是LI,容器元素都有这个问题!现象:LI里有浮动对象而LI本身不浮动的时候,IE里就会有2像素的下边距解决:1、设定LI的浮动;2、IE HAC...

不光是LI,容器元素都有这个问题!

现象:LI里有浮动对象而LI本身不浮动的时候,IE里就会有2像素的下边距

解决:1、设定LI的浮动;2、IE HACK

推荐使用方案1,设置LI的宽度和浮动

方案2代码参考:

*html .xuxiao li{margin-bottom:-2px;}/**IE 6**/

*+html .xuxiao li{margin-bottom:-2px;}/**IE 7**/

以下是对于<LI>元素产生间距问题的另一种解决方法

<script>//获取一个对象function getByid(id) { if (document.getElementById) { return document.getElementById(id); } else if (document.all) { return document.all[id]; } else if (document.layers) { return document.layers[id]; } else { return null; }}//运行框操作function creatID(DivID){var objs=getByid(DivID).getElementsByTagName('textarea');var inps=getByid(DivID).getElementsByTagName('input');var buts=getByid(DivID).getElementsByTagName('button');var labs=getByid(DivID).getElementsByTagName('label'); for (i=0; i

 提示:可先修改再运行,如无效果,请刷新页面!

当li元素设置了高度,且li内元素浮动时会触发该bug。

解决方法:
li设置css
vertical-align: bottom;

 提示:可先修改再运行,如无效果,请刷新页面!



相关热词搜索:

 
上一篇:css 高度自动适应 让IE6也有最小高度min-height效果
下一篇:网站变黑白色CSS一行代码实现
收藏 将此文推荐给朋友
分享到: