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

CSS样式表
css 兼容ie6,ie7,ff的fixed,元素上下端固定定位方法
CSS解决链接锚点定位偏移的代码
一个css transform效果 很有图片的感觉
ie6,ie7,firefox的textarea滚动条、边框
12种CSS BUG解决方法与技巧
CSS 常用设置备忘
table中td内容换行问题
外部引用CSS中 link与@import的区别
CSS background-position 属性 定位图片
css 解决英文字符与阿位伯数字自动换行
div ,frame等空间的透明实现代码
CSS中几种浏览器对不同版本的支持与区分写法
多个浏览器对容器宽度实际像素的解释
CSS 用ul li做圆角表格
CSS 之dl dt dd模拟表格实例代码
创建超链接及css 样式设置
页面位置 top、postop、scrolltop、offsetTop、scrollHeight、offsetHeight、clientHe
css float 解析学习
学习DIV+CSS难不难 需要掌握哪些知识
IE8 CSS hack

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


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