当前位置: 首页 > 图文教程 > 网页制作 > CSS样式表 > IE6使用浮动去掉元素中的多余空白间距

CSS样式表
CSS中box(盒模式)的分析
CSS2快速参考
CSS布局入门
怎么改善现有网站
display&position
表格斜线
转载:On having layout
标准化你的网页
HTML技巧汇编
动态CSS站点教程:多个页面样式提供浏览者选择
鲜为人知的CSS技巧10则
详谈 CSS样式表使用:链接/嵌入
W3C标准:实时切换CSS样式
On having layout
XHTML与HTML之间的区别
XHTML标准语法
针对浏览器隐藏CSS
CSS基础学习
130个漂亮CSS布局站点参考
css技巧十条

CSS样式表 中的 IE6使用浮动去掉元素中的多余空白间距


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-03   浏览: 328 ::
收藏到网摘: n/a

IE6的某些元素在表现上有多余的一些空白间隙,或者更形象的说是“外边距(margin)”,要么是margin-top,要么是margin-bottom,当然还有margin-left,margin-right。这个在表单元素中特别常见。即使我们的reset css已经将这些元素的margin值设为0。
可以看一个实例:比如们想模拟一个双边框的文本框,如图:

 

看html代码:
1.<span><input type="text" name="textfield2" id="textfield2" /></span>
css代码:
1.span{border:1px solid #FCCC83; display:inline-block; overflow:hidden; zoom:1}
2.
 
3..url-input{ width:200px; height:18px; background-color:#FFFFFF;   padding:2px 0 0 3px; border:1px solid #FA9806;}
其他浏览器下正常,但是ie6下(ie7下未测试),如图显示:

 

span和input之间明显有个间距。这个时候直接无语了。即使我们将input设为margin:0; padding:0;
百般无奈下只能使input浮动,因为以前也碰到过类似的问题——【IE6的疯狂之六】li在IE中底部3像素的BUG(增加浮动解决问题)
看html代码:
1.<div>输入视频、网页、音乐的地址: <span><input type="text" name="textfield2" id="textfield2" /></span> <input type="submit" name="button" id=""  value="分享" /> </div>
css代码:
view sourceprint?1.*{ margin:0; padding:0;  font-size:12px}
2..share-submit{margin:5px 0 20px; background-color:#F9FBFC; border:1px solid #D1D6E2; padding:8px; overflow:hidden; zoom:1; width:550px; margin:20px auto }
3..share-submit .url-input{width:200px;height:18px;background-color:#FFFFFF;   padding:2px 0 0 3px; float:left;border:1px solid #FA9806}
4..share-submit span,.share-submit input{ vertical-align:middle}
5..share-submit span{border:1px solid #FCCC83; display:inline-block; overflow:hidden; zoom:1}

该问题我昨天也拿到css森林讨论,期待有更好的解决方法,开始没有找到
经过次测试,这个方法屡试不爽,虽然不知道原因但是也算是一个解决方案了。欢迎留言说出您的解决方法,欢迎拍砖!,如果您知道原因欢迎留言告知,感激不尽!