📜  如何在 Javascript 代码示例中在图像上添加动画

📅  最后修改于: 2022-03-11 15:01:11.782000             🧑  作者: Mango

代码示例1
function startAnimation() {
    var frameHeight = 102;
    var frames = 15;
    var frame = 0;
    var div = document.getElementById("animation");
    setInterval(function () {
        var frameOffset = (++frame % frames) * -frameHeight;
        div.style.backgroundPosition = "0px " + frameOffset + "px";
    }, 100);
}