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

CSS样式表
分页显示之超级提速版
兼容多浏览器实现半透明(Opera ie firefox)
解析IE, FireFox, Opera 浏览器支持Alpha透明的方法
utf8和unicode编码究竟是什么关系?有何区别?
XHTML下css+div布局总结 超强推荐
在IE下拖动滚动条时border消失的解决方法
CSS中常用的单位
有关表格边框的css语法整理(1)
中文排版CSS心得
一个针对IE7的CSS Hack
css也疯狂! 用background 插入flash播放器
如何解决下拉菜单被flash覆盖的问题
网页中关闭IE的图像工具栏和XP主题
解决IE升级后Flash线框问题
em px的关系
在iframe中隐藏横向滚动条的方法大全
Iframe自适应其加载的内容高度
固定右栏宽度, 左栏内容先出现同时自适应宽度的布局
IE Bug--浮动对象外补丁的双倍距离的解决方法
解决IE7以下版本不支持无A状态伪类的几种方法

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


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