IE7原因“文本 - 空文本节点” [英] IE7 cause of "Text - Empty Text Node"

查看:233
本文介绍了IE7原因“文本 - 空文本节点”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用IE网络开发者工具栏排查问题。列表项下面出现一个空白的空白,我无法从逻辑上找出原因。使用web开发工具栏,我看到在下面的示例1中,文本 - 空文本节点正在文本 - Google下输出。讽刺的是,在第二个,在单词Google之后手动插入空格,该文本节点不再显示。如果结果被扭转,这对我来说是完全有意义的。任何想法可能导致这种奇怪的行为?

I'm using the IE web developer toolbar to troubleshoot an issue. A blank white space is appearing below a list item, and I can't logically figure out why. Using the web dev toolbar, I see that in example 1 below, a "Text - Empty Text Node" is being output below "Text - Google". Ironically, in the second, with a space manually inserted after the word "Google", that text node no longer appears. It would make complete sense to me if the results were reversed. Any ideas what may cause this odd behavior?

注意:这是在IE7中发生的,但不是IE8。

Note: this is occuring in IE7, but not IE8.

<li><a href="www.google.com">Google</a></li> - empty text node appears at end

<li><a href="www.google.com">Google </a></li> - no empty text node

更新:Ok我已经缩小了这个问题。基本上,似乎在我使用的一些属性之间的冲突。我需要一个标签显示为块,所以当有多行时,它们将正确包装。但我也不需要在项目之间的空白空间。我不太确定为什么空白空间解决了这个问题,并且不希望只是攻击它。

Update: Ok I've narrowed down this issue. Basically, it seems like there's a conflict between some of the attributes I'm using. I need the a tags to be display as block, so they will wrap correctly when there are multiple lines. But I also need no empty space in between the items. I'm not quite sure why that empty space solves the problem, and would prefer not to just "hack" it.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<style type="text/css">
a
{
    display:block;
}
li
{
    zoom: 1;
}
</style>
    </head>
<body>
    <ul>
        <li>
        <div style="background-color:blue">
            <a href="#"><img  src="http://www.google.com/intl/en_ALL/images/logo.gif"/></a>
        </div>
            <ul>
                <li style="background-color:Red"><a href="#">One</a></li>
                <li style="background-color:green"><a href="#">Two </a></li>
                <li style="background-color:Yellow"><a href="#">Three</a></li>
            </ul>
        </li>
    </ul>
</body>
</html>


推荐答案

现在< a> 是块级元素,您必须给它hasLayout。

Now that the <a> is a block level element, you have to give it hasLayout too.

a
{
    display:block;
    zoom:1;
}

这篇关于IE7原因“文本 - 空文本节点”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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