display:inline-block和text-indent

Dan*_*ani 6 css internet-explorer-8 internet-explorer-7

我在某些版本的Internet Explorer中遇到以下代码的问题:

#iconautente{ 
background-image:url('/style/images/spritecommon.png'); /*icona_utente.png*/
background-position:-117px -15px;
text-indent:-9000px;
width:20px;
height:23px;
display:inline-block;
}

<a id="iconautente" href="/admin/index.php">admin</a>
Run Code Online (Sandbox Code Playgroud)

在Vista下的Firefox,IE7和IE8中,我看到了背景和没有文字,正如预期的那样.在XP下的IE6和IE8中,整个图像是缩进的,而不是文本,因此不显示图像.

什么应该是正确的行为?有解决方法吗?

zhi*_*lee 5

也许你可以尝试这样:

.blk {  display:inline-block; height:96px; width:96px; text-indent:-9999px; *text-indent:0; *font-size:0; *line-height:0; *overflow:hidden; }

参见演示http://jsfiddle.net/zhiyelee/4aRZa/


Fat*_*ğlu 1

* html #iconautente{text-indent:0; line-height:0; font-size:0; overflow:hidden}/*ie6 hack */

*:first-child+html #iconautente{ text-indent:0; line-height:0; font-size:0; overflow:hidden}/*ie7 hack */
Run Code Online (Sandbox Code Playgroud)

  • 文本仍然以非常小的字体显示在 Chrome 浏览器中(看起来像一串点)。 (3认同)