css opacità non funziona correttamente in IE 6 / IE7 o IE8 in modalità di compatibilità
Domanda
Nel codice seguente al primo e secondo le immagini con ancore hanno collegamenti e in queste immagini il testo della didascalia non nasconde (opacità 0) al caricamento della pagina in IE 6 / IE7 o IE8 in modalità Comp. Tutte le altre immagini funzionano bene, ma ho bisogno di collegamenti, ma in loro.
Ecco il codice in JSfiddle
FF funziona bene e IE8 in modalità normale va bene così
vorrei inviare l'intero codice qui, ma la sua piuttosto lunga e ho avuto difficoltà a farlo.
AGGIUNTO js codice
$(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);
});
});
Sembra di non così ...
$(this).css('opacity', 0);
Soluzione
E 'un hasLayout bug . È possibile risolvere il problema con l'aggiunta di zoom: 1
al tuo div.wrapper dichiarazione di classe CSS:
div.wrapper{
zoom: 1;
position:relative;
}
Altri suggerimenti
IE prima della versione 8 non supporta l'applicazione ufficiale di opacità. Mentre la versione ufficiale è
opacity: [0..1]
attuazione di IE prima versione 8 (e quindi, modalità di compatibilità di IE8, che agisce come IE7) è presente
filter: alpha(opacity=[0..100])
Prova questi per almeno IE7 e 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 modificato per utilizzare il suo codice da jsbin
provare questo css
.transparent {
filter:alpha(opacity=50);
-moz-opacity:0.5;
-khtml-opacity: 0.5;
opacity: 0.5;
}
e la classe add con JQuery
$('div.description').each(function(){
//...set the opacity to 0...
$(this).addClass('transparent')
...