在下面的代码中,带有锚点的第一个和第二个图像具有链接,在这些图像中,标题文本在IE 6 / IE7或IE8中的页面加载时不会隐藏(不透明度0)。所有其他图像工作正常,但我需要链接在其中。
以下是JSfiddle
中的代码FF工作正常,IE8在正常模式下也很好
我会在这里发布整个代码,但它相当长,而我却遇到了麻烦。
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);
});
});
似乎不喜欢这个......
$(this).css('opacity', 0);
答案 0 :(得分:8)
这是一个hasLayout bug。您可以通过将zoom: 1
添加到 div.wrapper 类CSS声明中来解决此问题:
div.wrapper{
zoom: 1;
position:relative;
}
答案 1 :(得分:2)
opacity: [0..1]
IE在版本8之前的实现(因此,IE8的兼容模式,就像IE7一样)是这个
filter: alpha(opacity=[0..100])
答案 2 :(得分:1)
至少尝试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)'
});
更新UPDATE以使用他在jsbin中的代码
答案 3 :(得分:1)
试试这个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')
...