I've been developing an open source project named BitDay that originated from a Reddit thread some time ago.
In this project, I have 12 CSS classes representing different elements, each with its own unique background image.
Currently, the jQuery script I wrote fetches the current time and dynamically changes the background image based on the time of day. This means that every 2 hours, the background will transition to a new image.
$(function() {
// JavaScript code here...
});
#container {
// CSS styles here...
}
.bg {
// Background styles here...
}
/* Define background images for various times of the day */
<div id="container">
<div class="bg-splash"></div>
<div class="bg-tobe" style="display: none;"></div>
</div>
Instead of instantaneously changing the background image depending on the hour, I'm looking to implement a gradual transition effect. For example, at 7am, bg-1 will be fully visible at 100% opacity. As time progresses, it will slowly fade into bg-2, reaching full opacity by 8am. This fading effect will continue throughout the morning, creating a smooth transition between backgrounds over the course of 2 hours.
Furthermore, I aim to make this transition persistent for all users accessing the start screen. This means that if a user logs in at 8:30am, they will see bg-1 displayed at 25% opacity, seamlessly blending into bg-2.
I'm grappling with the implementation details on this feature and would greatly appreciate any assistance or insights!