Color “transparent” not working

2020-05-20 11:54发布

I have a problem with the IE (what else?):

I generate content with CSS which has also a background-image. I looks like that:

#nav ul li:after {
    content: "--";
    position: relative;
    z-index: 99;
    background: transparent url(image.png);
    color: transparent;
}

The text color is in non-IE-browsers transparent, but in all IE browsers (IE6-IE8) it's black and you could see it. How could I make the text transparent/unvisible?

I tried already: visibility - opacity - filter - text-indent ... But none did his job right, either it disappears (with it background which I need) or the attribute doesn't apply.

10条回答
叛逆
2楼-- · 2020-05-20 12:32

I see you're using a PNG as your background image. Normally, if you're using IE 6, there is a fix for PNG transparency (http://www.twinhelix.com/css/iepngfix/). Even so, this will not work with background-images. So if you're using IE 6, there really isn't a fix.

查看更多
Emotional °昔
3楼-- · 2020-05-20 12:37

I think no versions of IE support color: transparent Perhaps you could try to do it with jQuery or something like that.

查看更多
老娘就宠你
4楼-- · 2020-05-20 12:38

If this doesn't work in Internet Explorer 8

font-size: 0;

make sure you're using a valid doctype:

<!DOCTYPE html>
查看更多
仙女界的扛把子
5楼-- · 2020-05-20 12:40

what about using line-height

line-height:0;

it worked in my case.

查看更多
干净又极端
6楼-- · 2020-05-20 12:42

I get it: With the correct padding and a zero font-size! Set the padding-left value to be one pixel beyond the image width.

查看更多
地球回转人心会变
7楼-- · 2020-05-20 12:43

For me color:transparent was not working in IE8, and it was showing text with default color. I used visibility:hidden; for IE8 only as the text was not required to display.

Hope this help in case, if the element is not required to display.

查看更多
登录 后发表回答