Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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;
}
like image 696
RGBK Avatar asked Oct 22 '10 13:10

RGBK


People also ask

Can a background color be transparent CSS?

The CSS color name transparent creates a completely transparent color. Using rgba or hsla color functions, that allow you to add the alpha channel (opacity) to the rgb and hsl functions. Their alpha values range from 0 - 1.

Can we set transparent value to the background color property?

Transparent color in CSS makes background elements visible from another top element of the page. Transparent color can be applied with background-color property and color. If we take background-color as transparent then it makes backside elements of background completely visible.

How do I make background color transparent in CSS?

To set the opacity of a background, image, text, or other element, you can use the CSS opacity property. Values for this property range from 0 to 1. If you set the property to 0, the styled element will be completely transparent (ie. invisible).

Which property is responsible for setting the background color?

The background-color CSS property sets the background color of an element.


2 Answers

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/

like image 129
meder omuraliev Avatar answered Nov 12 '22 20:11

meder omuraliev


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.

like image 31
Mathijas Avatar answered Nov 12 '22 20:11

Mathijas