I'm developing a site that has multiple high resolution images that are used as the content div background image. Every 7 seconds I call a function to set the background image which uses the below code.
document.getElementById('main_content_div').style.background = 'linear-gradient(to right, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.6)),url('+url+')';
The CSS for main_content_div states there should be a transition but it's not occurring.
position:relative;
height:1080px;
background-color:#000;
background-image: linear-gradient(to right, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.6)),url('/img/background/bg8.jpg');
background-size:cover;
transition: background-image 3s ease-in-out;
Every time the background updates I get no transition and some times I can see the gradient appear before the image appears which looks really bad.
If I take the linear gradient out the background image does transition nicely but I need the gradient overlay to make the text over the background images readable.
I've tried every rendition I can google for, using before and after selectors, using jquery animate option, I've had no luck. Please tell me how I should be accomplishing this.