Below is a snippet of my JavaScript code:
<script>
function random(n) {
return ((Math.floor(Math.random() * Math.floor(n)))+1);
}
var x = random(5000)+2000;
</script>
In addition, I have some CSS:
<style>
.fadingVariable{animation:fading 7s infinite}@keyframes fading{0%{opacity:0}20%{opacity:1}50%{opacity:1}80%{opacity:1}100%{opacity:0}}
</style>
The CSS above fades an image in and out every 7 seconds. I want to make this time interval variable using the 'x' value from my JavaScript. How can I achieve this? Can I simply write it like this:
<style>
.fadingVariable{animation:fading 'x's infinite}@keyframes fading{0%{opacity:0}20%{opacity:1}50%{opacity:1}80%{opacity:1}100%{opacity:0}}
</style>