I am trying to make a splash screen that disappears after 4 seconds. I am trying to do this by adding the display-none class to the splash class through JS, but the class is not being added, so the splash screen is still being displayed. Here is the codepen of the issue:
https://codepen.io/dbake3452/pen/VwmeoGa
///HTML
<div class="splash">
<img class="fade-in" src="images/pippinhop.png">
</div>
///SASS
.splash {
width: 100%;
height: 100vh;
background-color: #a9aaff;
position: fixed;
top: 0;
left: 0;
z-index: 2;
display: flex;
align-items: center;
justify-content: center;
.display-none {
display: none;
};
img {
width: 12.5%;
}
}
@keyframes fadeIn{
to {
opacity: 1;
}
}
.fade-in {
opacity: 0;
animation: fadeIn 1s ease-in forwards;
}
///JS
const splash = document.querySelector('.splash');
document.addEventListener('DOMContentLoaded', (e) => {
setTimeout(() => {
splash.classList.add('display-none');
}, 4000);
});'