I have been trying to smooth out the transitions on this snippet of code but I don't understand why that transition is not working. I'm trying to not use anything outside of vanilla HTML, CSS, and JavaScript. I know I can achieve a similar result with pure CSS using key animations but I'm very curious if it can be done using mostly js. How can this be done?
<head>
<style>
*{
transition: all 5s !important;
}
div{
width: 100vw;
height: 100vh;
}
</style>
</head>
<div id='gradient'>
<h1>hello</h1>
</div>
<script>
document.querySelector("#gradient").style.backgroundImage= 'linear-gradient(60deg, #3d3393 0%, #2b76b9 37%, #2cacd1 65%, #35eb93 100%)';
function dynamicGradient() {
let color1 = `rgb(${Math.random()*100+55},${51},${Math.random()*20+100})`
let color2 = `rgb(${Math.random()*10+13},${78},${Math.random()*10+135})`
let color3 = `rgb(${Math.random()*10+14},${Math.random()*5+184},${Math.random()*10+160})`
let color4 = `rgb(${Math.random()*5+28},${Math.random()*10+185},${Math.random()*10+67})`
let linearGradient = `linear-gradient(60deg, ${color1} 10%, ${color2} 37%, ${color3} 65%, ${color4} 100%)`
document.querySelector("#gradient").style.backgroundImage = linearGradient;
document.querySelector("#gradient").style.backgroundImage.filter = 'blur(200px)';
console.log('called')
}
setInterval(() => {
dynamicGradient()
}, 800);</script>