views:

271

answers:

2

Hi,

I'm trying to get this thing to work in IE (any version - works in FF, Opera, Safari, Chrome ...):

I have a DIV with a background-image. The DIV also contains an image that should be transparent onMouseOver. The expected behaviour now is that the DIV-background would shine through the transparent image (which it does in all browsers but IE).
Instead it looks like the image is getting transparent but on a white background, I can't see the DIV's background through the image.

Here's some code:

<div><a href="#" class"dragItem"><img /></a></div>

And some CSS:

  .dojoDndItemOver {
    cursor         : pointer;
    filter         : alpha(opacity = 50);
    opacity        : 0.5;
    -moz-opacity   : 0.5;
    -khtml-opacity : 0.5;
  }
  .dragItem:hover {
    filter         : alpha(opacity = 30);
    opacity        : 0.3;
    -moz-opacity   : 0.3;
    -khtml-opacity : 0.3;
    background     : none;
  }

All of this is embedded in a Dojo Drag-n-Drop-system, so dojoDndItemOver will automatically be set to the DIV on MouseOver, dragItem is set to the href around the image (using the same class on the image directly doesn't work at all as IE doesn't support "hover" on other items that href).

Any ideas? Or is it an IE-speciality to just "simulate" transparency on images by somehow just greying them out instead of providing real transparency and showing whatever is beneath?

A: 

IE uses the CSS filter:alpha(opacity=x) taken from w3Schools CSS Image transparency. You can also apply it to DIV backgrounds.

div.transbox
  {
  width:400px;
  height:180px;
  margin:30px 50px;
  background-color:#ffffff;
  border:1px solid black;
  /* for IE */
  filter:alpha(opacity=60);
  /* CSS3 standard */
  opacity:0.6;
  }

I think that filters are a bad idea, so also you can use transparent pngs with IE as shown here.

Kyle Sevenoaks
I'm already using filters (see my CSS above) and I don't want to make a background transparent but an image (which can be in any format) to make the unerlying background shine through, also using a transparent PNG would require a second image which is not really an option.
Select0r
Ok, well maybe this article will help you: http://24ways.org/2007/supersleight-transparent-png-in-ie6:)
Kyle Sevenoaks
+1  A: 
a.dragItem {/*Background behind the image*/}
a.dragItem img {/*Image is opaque, hiding the background*/}
a.dragItem:hover img {/*Image is transparent, revealing the background*/}
Alexander
`a.dragItem:hover img` did the trick, thanks a lot!
Select0r