CSS不透明度はIE 6 / IE7またはIE8で互換モードで正しく機能しません
質問
次のコードでは、アンカーを備えた最初の画像と2番目の画像にリンクがあり、これらの画像では、CompモードのIE 6 / IE7またはIE8のページの読み込みにキャプションテキストが非表示(不透明度0)になりません。他のすべての画像は正常に動作しますが、私はそれらにリンクするだけです。
これがコードです jsfiddle
FFは正常に動作し、通常モードのIE8も問題ありません
私はここにコード全体を投稿しますが、それはかなり長く、私はそうするのに苦労していました。
JSコードを追加しました
$(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);
});
});
これが好きではないようです...
$(this).css('opacity', 0);
解決
それは Haslayoutバグ. 。追加して修正できます zoom: 1
あなたに div.wrapper クラスCSS宣言:
div.wrapper{
zoom: 1;
position:relative;
}
修理 ここで動作しています.
他のヒント
IE前のバージョン8は、不透明度の公式実装をサポートしていません。公式バージョンはそうです
opacity: [0..1]
IEのバージョン8の前の実装(したがって、IE7のように機能するIE8の互換モード)はこれです
filter: alpha(opacity=[0..100])
少なくともIE7と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)'
});
JSBINのコードを使用するために編集された更新
このCSSを試してください
.transparent {
filter:alpha(opacity=50);
-moz-opacity:0.5;
-khtml-opacity: 0.5;
opacity: 0.5;
}
そして、jQueryにクラスを追加します
$('div.description').each(function(){
//...set the opacity to 0...
$(this).addClass('transparent')
...
所属していません StackOverflow