5

当我运行下面的代码时,我在屏幕上看到一个蓝色框。

<!DOCTYPE html>
<html dir="ltr">
    <head>
        <meta http-equiv="Content-type" content="text/html; charset=utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <style type="text/css">
                a {display:block;background:blue; text-indent:-9999px; float:left;}
        </style>
    </head>

    <body>
        <a>Hello World</a>
    </body>
</html>

如果我将文本更改Hello WorldHelloWorld,蓝色框消失了怎么办?

附加说明- 我在 google chrome 中看到了这一点。

4

1 回答 1

5

正如我在评论中所说,white-space: nowrap让它消失。

但是,我不确定这里实际发生了什么。Chrome/Safari + Opera 都以相同的方式显示“蓝框”,而 Firefox 和 IE7-9 不显示蓝框。

您的代码:http: //jsbin.com/igewuy

使用white-space: nowrap“修复”:http: //jsbin.com/igewuy/2

于 2011-10-21T23:10:05.580 回答