色婷婷狠狠18禁久久YY,CHINESE性内射高清国产,国产女人18毛片水真多1,国产AV在线观看

如何制作隨機(jī)css動(dòng)畫時(shí)間?

我現(xiàn)在正在做谷歌恐龍項(xiàng)目,我想做一個(gè)隨機(jī)仙人掌動(dòng)畫時(shí)間和延遲,但我不知道如何,這里是我的代碼:

`.cactus-anim {
    animation: cactus-move 1.3s 0.5s linear infinite;

}

@keyframes cactus-move {
    0% {
        left: 700px;
    }

    100% {
        left: -40px;
    }
}`

(我想用1.3秒來(lái)代替隨機(jī)(1-2)秒,用0.5秒來(lái)代替隨機(jī)(0-0.7)秒,我也用Scss和Js,Thnks

您可以將這段代碼添加到JS中,并在需要隨機(jī)化動(dòng)畫時(shí)間時(shí)運(yùn)行它,但這在普通CSS中是不可能的。

const anim = document.querySelector(".cactus-anim");

// gets a random number between 2 values
function randNum(min, max) {
    return Math.random() * (max - min) + min
}

// run this function to set a new, random animation time
function randAnimTime() {
    // sets the new animation time
    // first time random is between 1 and 2 seconds
    // second is random between 0 and 0.7 seconds
    anim.style.animation = "cactus-move " + randNum(1, 2) + "s " + randNum(0, 0.7) + "s linear infinite";
}

上一篇vue id和ref
下一篇vue icon-font