BackgroundImage转换在f​​irefox上不起作用

时间:2016-01-17 17:52:17

标签: javascript css firefox transition

我在javascript中使用转换但在firefox上不起作用,有人知道为什么吗?谷歌铬是好的。 这是我的代码:

el.style.backgroundImage = "url('menu.jpg')";
el.style.transition = "background 0.4s";

1 个答案:

答案 0 :(得分:0)

根据@Jeremy发布的链接建议;替换设置transition以影响background-size

opacity



div a {
  color: #fff;
  z-Index: 3;
  position: absolute;
}
div:before,
div:after {
  content: " ";
  position: absolute;
  background-repeat: no-repeat;
  display: block;
  width: 50px;
  height: 50px;
  transition: background-size 0.4s;
}
div:before {
  background: #1F1F1F;
  background-size: 100% 100%;
}
div:after {
  background: url(http://lorempixel.com/50/50/nature);
  background-size: 0% 0%;
}
div:hover:before {
  background-size: 0% 0%;
}
div:hover:after {
  background-size: 100% 100%;
}

<div><a href="#">abc</a>
</div>
&#13;
&#13;
&#13;

plnkr http://plnkr.co/edit/XJMvtEnuvS1TF1xqIVVQ?p=preview