IE图像间距问题 [英] IE image spacing issue

查看:64
本文介绍了IE图像间距问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个图像上面的div,和IE(7,可能是6)坚持在两者之间放一个空格。如何摆脱这个空间?

I have an image above a div, and IE (7, and presumably 6) insists on putting a space between the two. How can I get rid of that space?

<html>
<body>
    <img src="http://www.google.com/intl/en_ALL/images/logo.gif" style="margin: 0; padding: 0;
        border: solid 1px black" />
    <div style="margin: 0; padding: 0; border: solid 1px green;width: 276">
        <a href="#">More...</a>&nbsp;
    </div>
</body>
</html>


推荐答案

默认情况下,IMG显示为inline,因此您将获得一行仅包含图像的文本,以及一个位于其下的div。文本行具有等于图像高度的上升和等于当前字体下降的下降(它来自图像和div之间的空间)。在严格模式下,即使没有空格,你也会得到下降。

IMG is display:inline by default, so you are getting a line of text that contains only image, and a div below it. The line of text has ascent that equals the height of the image and descent that equals descent of current font (which comes from the space between the image and the div). In strict mode, you will get descent even without the space.

因此,另一种消除差距的方法是通过指定行高来将下降设置为零:0(在父元素上)。

So, another way to get rid of the gap is to set the descent to zero by specifying line-height:0 (on the parent element).

这篇关于IE图像间距问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆