views:

201

answers:

4

In the following code the first and second images with anchors have links and in these images the caption text does not hide (opacity 0) on page load in IE 6 / IE7 or IE8 in Comp mode. All other images work fine but I need to but links in them.

Here is the code in JSfiddle

FF works fine and IE8 in normal mode is fine as well

I would post the whole code here but its rather long and I was having trouble doing so.

ADDED js code

$(window).load(function(){
//for each description div...
$('div.description').each(function(){
    //...set the opacity to 0...
$(this).css('opacity', 0);
    //..set width same as the image...
    $(this).css('width', $(this).siblings('img').width());
    //...get the parent (the wrapper) and set it's width same as the image width... '
    $(this).parent().css('width', $(this).siblings('img').width());
    //...set the display to block
    $(this).css('display', 'inline-block');
});
$('div.wrapper').hover(function(){
    //when mouse hover over the wrapper div
    //get it's children elements with class descriptio
    //and show it using fadeTo
    //$(this).children('.description').show();
    $(this).children('.description').stop().fadeTo(500, 0.7);
},function(){
    //when mouse out of the wrapper div
    //use fadeTo to hide the div
    $(this).children('.description').stop().fadeTo(500, 0);
});
});

It seems to not like this...

$(this).css('opacity', 0);
+1  A: 

Try these for at least IE7 and 8:

.opaque1 {  // for all other browsers
    opacity: .5;
}

.opaque2 {  // for IE5-7
    filter: alpha(opacity=50);
}

.opaque3 {  // for IE8
    -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
}




$(this).css(
  {
     'opacity': 0,
     '-ms-filter':"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)",
     'filter': 'alpha(opacity=50)'
   });

UPDATE edited to use his code from jsbin

d2burke
Well, according to the OP, the official opacity spec works in IE8. IE8 in compatibility mode is almost the same as IE7, so `.opaque2` should cover that.
Delan Azabani
it does not work in ie8 compatibility mode
well I tried it in JSfiddle and still not working, the first two captions are still there
+1  A: 

IE before version 8 doesn't support the official implementation of opacity. While the official version is

opacity: [0..1]

IE's implementation before version 8 (and hence, IE8's compatibility mode, which acts like IE7) is this

filter: alpha(opacity=[0..100])
Delan Azabani
+1  A: 

try this css

.transparent {
    filter:alpha(opacity=50);
    -moz-opacity:0.5;
    -khtml-opacity: 0.5;
    opacity: 0.5;
}

and add class whith JQuery

$('div.description').each(function(){
    //...set the opacity to 0...
$(this).addClass('transparent')
...
jcubic
I added the css to the description class directly but still not working. http://jsfiddle.net/vAMyh/7/, Why when you add the link does behave this way? Stumped!!!
+3  A: 

It's a hasLayout bug. You can fix it by adding zoom: 1 to your div.wrapper class CSS declaration:

div.wrapper{
    zoom: 1;
    position:relative;  
}

Fix in action here.

Pat
Wow nice find!!!!! never would have gotten that. $#@$@$@$ IE #@$@#$@
man, good work Pat ./\.
d2burke
Any idea what triggered it?
@d2burke thanks - adding zoom: 1 has become my default fix whenever IE is wasting my time. @user357034 Not entirely - when I noticed that the overlay hover worked on items without an `<a>` I figured it must've had something to do with the `div.wrapper` not containing its children properly.
Pat
Well thanks again for the great find!!!! Hats off to ya...