jQuery背景动画初始不透明度只在IE中出错

时间:2012-08-07 05:11:27

标签: jquery html css

我正在设置div的背景,以便产生您在http://farshadzandi.ca上看到的金色按钮效果

代码如下:

$(function(){
  $(".navigation").hover(function(){
    $(this).children('.background').stop(true,true).animate({opacity: 1},250);
  }, function(){
    $(this).children('.background').stop(true,true).animate({opacity: 0},250);
  });
});

$(function(){
  $(".lower-navigation").hover(function(){
    $(this).children('.lower-background').stop(true,true).animate({opacity: 1},250);
  }, function(){
    $(this).children('.lower-background').stop(true,true).animate({opacity: 0},250);
  });
});

任何人都可以告诉我为什么虽然这在Firefox / Chrome中运行得很好,但是当页面加载时它会在IE中显示背景图像吗?谢谢!

1 个答案:

答案 0 :(得分:1)

对于IE,您必须使用以下CSS语法。

/* IE 8 */
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";

/* IE 5-7 */
filter: alpha(opacity=50);