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

CSS样式表
做网页中需要掌握的八个CSS布局技巧
CSS属性 - white-space 空白属性使用说明
用CSS构建iframe效果代码
用div+css解决出现水平滚动条问题
ul在Firefox和IE下的不同表现的解决方法
用css实现隐藏文本框
css实现行间距效果
研究了一下div+css的高度自适应问题
做网页字体大小参考 网页中同字号字体的不同单位对比列表
css 之 background-position-x
css实现兼容各个浏览器的技巧的代码
css中的行间距的代码
HTML:scrollLeft,scrollWidth,clientWidth,offsetWidth完全详解
scrollWidth,clientWidth与offsetWidth的区别
大家需要掌握的 html下SPAN和DIV的区别
布局用CSS+DIV的优点总结
纯CSS生成抗锯齿圆角的代码
IE6,IE7和firefox对DIV的支持区别
DIV+CSS布局的网站对网站SEO的影响分析
非常不错的关于IE与FireFox的js和css几处不同点[转自星火燎原]

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-03   浏览: 385 ::
收藏到网摘: 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森林讨论,期待有更好的解决方法,开始没有找到
经过次测试,这个方法屡试不爽,虽然不知道原因但是也算是一个解决方案了。欢迎留言说出您的解决方法,欢迎拍砖!,如果您知道原因欢迎留言告知,感激不尽!