I have the following jQuery to change the body
background image.
(function($, interval, slides) {
var gradient = "linear-gradient(0deg,rgba(0,0,255,0.3),rgba(0,0,255,0.3))";
$('body').css("background", gradient+", url('" + slides[slides.length-1] + "')");
var i = 0;
var handle = setInterval(function () {
var bg = gradient+", url('" + slides[i] + "')";
$('body').css('background', bg);
i++;
if (i >= slides.length) {
i = 0;
}
}, interval);
})(jQuery, 5000, [
"https://source.unsplash.com/CgOaFB56Vyw/1920x1080",
"https://source.unsplash.com/18Q4c6EVf_o/1920x1080",
"https://source.unsplash.com/7uvHtSn5a90/1920x1080"
]);
Now the problem I am facing is, the change in background property changes are not smooth. Is there any way that I can use the transition
property here to ease the change in the background image and gradient and to make it more smooth?. I have tried using transition: background-image 3s ease
but this has no effect. Please find my code in the following fiddle.