Kevin Powell - CommunityKP-C
Kevin Powell - Communityβ€’15mo agoβ€’
3 replies
R.I.P

get a random number after keyframes done its work / just get a random number every second

hi guys
let x 
    x =
    Math.floor(Math.random() * 100);
    var r = document.querySelector(':root');
    function set1() {
  // Set the value of variable --blue to another value (in this case "lightblue")
    r.style.setProperty('--at11', x + '%');
}
window.onload = set1;

ok so now i inserted the x% in the --at11 which is a %
but i need sth so like every second it gives me a new random number what should i do?
the reason i need it:(css)
@keyframe animation-goes{
10%{--sth : var(--at11)
    }
20%{--sth : var(--at11)
    }
30%{--sth : var(--at11)
    }
......
}
so i need it to change the animation all the time and be random (this is a simple example not the real deal)
Was this page helpful?