开发者

IE CSS Bug: background-color: transparent behaves differently to background-color: (any other colour)

开发者 https://www.devze.com 2023-01-22 01:52 出处:网络
I have been struggling to find out why this rollover is not behaving as it should in IE8. Go here: http://baked-beans.tv in IE8, you\'ll see that the rollover only works on the lower half of the thum

I have been struggling to find out why this rollover is not behaving as it should in IE8.

Go here: http://baked-beans.tv in IE8, you'll see that the rollover only works on the lower half of the thumbnails.

Btw, this is not activated by an <a> tag but by a :hover for the <div>.

What I can't figure out is why it works on only the lower half of the div, below the image, but not on the image (the image is not z-indexed so thats not the issue)

As soon as I change the background-color to anything else besides transparent, it works 100%. So this just blows my mind... why the bottom half, but not the top half, and only when I set bg-color to transparent?! Gotta love Internet Explorer.

This works as it should on every other browser (the entire square acts as a rollover)

Here's the CSS:

.cat_rollout {
    position: absolute;
    float:left;
    top:0;
    left:0;
    min-height:274px;
    min-width:274px;
    font-size: 0;
    background-color: transparent;
}

.cat_rollout:hover {
    background-image: url(images/rollover.png);
    min-width:254px;
    min-height:242px;
    padding-left: 20px;
    color: white;
    font-size: 21px;
    font-weight: normal;
    line-height: 24px;
    padding-top: 34px;
}开发者_如何学运维


Try faking a background image or setting it to a blank.gif instead of making it transparent.

background:url(blank.gif);

See http://work.arounds.org/issue/22/positioned-anchor-not-clickable-ie6/


The problem is that for some time (a week? two weeks?) IE has changed the way it interprets background-color. It seems that you cannot say, that the color is transparent, rather the whole background. So you should change background-color: transparent into background: transparent. Very nasty.


The same problem has been witnessed, where hovering on a transparent element's blank area doesn't make css rules related to hover take effects. The problem is fixed with giving the element the following style.

background-color: rgba(0, 0, 0, 0.001);


You could also try changing the hover selector to :

 .thumb_container:hover .cat_rollout {...}

so that the parent containment div is the element reacting to the hover.


You can use an 1x1 transparent gif as a datauri if you'd rather.

background-image:url(data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==);

Up to you which one you'd prefer, this works and is an alternative to the selected answer.

0

精彩评论

暂无评论...
验证码 换一张
取 消