background-image for firefox in CSS3 animations

2019-08-03 09:43发布

I am making keyframe animation in CSS. The animation seems to be working very well in Chrome as the -webkit syntaxes are supported.

@-webkit-keyframes title_toggle 
{
from { background-image:url(images/title.png); }
75%{ background-image:url(images/title_hover.png); }
to { background-image:url(images/title.png); }
}

I tried the code below for Firefox, but its not working

@-moz-keyframes title_toggle {
from { background-image:url(images/title.png); }
75%{ background-image:url(images/title_hover.png); }
to { background-image:url(images/title.png); }
}

Please let me know I would this work in FF.

This is the CSS part.

@-moz-keyframes title_toggle {
from { background-image:url(images/title.png); }
75%{ background-image:url(images/title_hover.png); }
to { background-image:url(images/title.png); }
}

.title{
    width:40%;
    height: 30%;
    position: absolute;
    top: 10%;
    left: 5%;
    background-size: 100% 100%;
    background-repeat:no-repeat;
    -webkit-animation-name: title_toggle;
    -webkit-animation-duration:5s;
    -webkit-animation-iteration-count:infinite;
    background-size: 100% 100%; 
     -moz-animation-name: title_toggle;
     -moz-animation-duration:5s;
     -moz-animation-iteration-count:infinite;
}

And this is the HTML

<div class="title"></div>

2条回答
三岁会撩人
2楼-- · 2019-08-03 10:09

If you're asking about the lack of cross-fade interpolation between different images, that's a very new addition to the spec that's not widely supported yet.

查看更多
趁早两清
3楼-- · 2019-08-03 10:13

This is not working because Firefox does not support animations on background images. Background-image is not animatable. Chrome has its own implementation but you won't get it working Firefox. https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_animated_properties

查看更多
登录 后发表回答