Is there a way to smoothly transition between background colors within a div
element?
I've been struggling with my code and couldn't find a solution. Any help would be greatly appreciated. Thanks in advance.
$(document).ready(function() {
var containerColors = [{
"background": "linear-gradient(to top right, #1abc9c, #3498db)"
},
{
"background": "linear-gradient(to top right, red, blue)"
}
];
$("#button").click(function() {
var random = Math.floor((Math.random() * 2));
$("#container").css(containerColors[random]);
});
});
#container {
height: 100vh;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="container" class="container-fluid">
<div class="box">
<button id="button">click</button>
</div>
</div>