I am making a website, and though that adding to it a splash screen would be nice and make the website much fancier. I made the code for it, but the issue, the text appears OK, but the text doesn't disappear after the set time which is 1 second it doesn't disappear, I mostly rechecked and didn't spot an error and when I run it, it works and no errors are given.
const splash = document.querySelector('.splash');
document.addEventListener('DOMContentLoaded', (e)=>{
setTimeout(()=>{
splash.classList.add('display-none');
}, 2000);
})
body {
padding: 0;
margin: 0;
background: black;
}
.navbar {
overflow: hidden;
padding: 5px;
margin: 0;
top: 0;
position: sticky;
background: black;
color: white;
opacity: 85%;
}
.navbar-item {
display: inline-block;
padding: 5px;
}
.left {
float: left;
font-weight: bold;
font-size: xx-large;
}
.right {
float: right;
font-size: x-large;
}
.no-style-link {
text-decoration: none;
color: inherit;
}
.main-content {
padding: 10px;
text-align: center;
}
.ytvidcollection {
padding: 10px;
background: #6969f8;
}
.ytvid {
padding: 5px;
background: red;
}
.ytvid:hover {
-ms-transform: scale(1.1);
transform: scale(1.1);
}
.copyright {
background: #333030;
color: white;
text-align: center;
bottom: 0;
font-size: x-large;
padding: 10px;
}
#Jothin-kumar {
font-size: xx-large;
text-decoration: none;
color: red;
}
#Jothin-kumar:hover {
text-decoration: underline;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Karan raj</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div >
<h1 >Welcome to My Website!</h1>
</div>
<ul >
<li ><a href="/">Karan raj</a></li>
<li ><a href="/">Home</a></li>
<li ><a href="/about">About</a></li>
<li ><a href="/contact">Contact</a></li>
</ul>
<div >
<iframe width=75% height="750" src="https://www.youtube.com/embed/gHn85Ytl_4w?controls=0&autoplay=1&modestbranding=1&rel=0" title="Trailer" allow="accelerometer; autoplay; clipboard-write; encrypted-media; picture-in-picture"></iframe>
<div >
<iframe width="560" height="315" src="https://www.youtube.com/embed/pFfOzZ97N2k?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/fZrw7x44UUA?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/XDUVT25yaYM?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/-C7l9q1CSOo?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/djoODhumDFk?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/rvilf-L2Hhw?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/8LnoVbcAPFA?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/0MH9ESonkiU?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/KJSu_8cialA?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/rYcMuSEZOBA?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/bSsH_uCwNbQ?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
<div >© Copyright 2022 <a href="https://jothin.tech" id="Jothin-kumar">Jothin kumar</a></div>
</body>
</html>
CodePudding user response:
using jquery,
document.addEventListener('DOMContentLoaded', (e)=>{
setTimeout(()=>{
$(".splash").css("display", "none");
}, 2000);
})
CodePudding user response:
You're adding a 'display-none' class but this isn't included anywhere in your CSS.
Just adding this to your CSS should fix it:
.display-none {
display: none;
}
const splash = document.querySelector('.splash');
document.addEventListener('DOMContentLoaded', (e)=>{
setTimeout(()=>{
splash.classList.add('display-none');
}, 2000);
})
body {
padding: 0;
margin: 0;
background: black;
}
.splash {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100vh;
overflow: hidden;
background-color: white;
z-index: 10;
display: flex;
align-items: center;
justify-content: center;
}
.display-none {
display: none;
}
.navbar {
overflow: hidden;
padding: 5px;
margin: 0;
top: 0;
position: sticky;
background: black;
color: white;
opacity: 85%;
}
.navbar-item {
display: inline-block;
padding: 5px;
}
.left {
float: left;
font-weight: bold;
font-size: xx-large;
}
.right {
float: right;
font-size: x-large;
}
.no-style-link {
text-decoration: none;
color: inherit;
}
.main-content {
padding: 10px;
text-align: center;
}
.ytvidcollection {
padding: 10px;
background: #6969f8;
}
.ytvid {
padding: 5px;
background: red;
}
.ytvid:hover {
-ms-transform: scale(1.1);
transform: scale(1.1);
}
.copyright {
background: #333030;
color: white;
text-align: center;
bottom: 0;
font-size: x-large;
padding: 10px;
}
#Jothin-kumar {
font-size: xx-large;
text-decoration: none;
color: red;
}
#Jothin-kumar:hover {
text-decoration: underline;
}
<div >
<div>Welcome to My Website!</div>
</div>
<ul >
<li ><a href="/">Karan raj</a></li>
<li ><a href="/">Home</a></li>
<li ><a href="/about">About</a></li>
<li ><a href="/contact">Contact</a></li>
</ul>
<div >
<iframe width=75% height="750" src="https://www.youtube.com/embed/gHn85Ytl_4w?controls=0&autoplay=1&modestbranding=1&rel=0" title="Trailer" allow="accelerometer; autoplay; clipboard-write; encrypted-media; picture-in-picture"></iframe>
<div >
<iframe width="560" height="315" src="https://www.youtube.com/embed/pFfOzZ97N2k?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/fZrw7x44UUA?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/XDUVT25yaYM?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/-C7l9q1CSOo?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/djoODhumDFk?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/rvilf-L2Hhw?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/8LnoVbcAPFA?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/0MH9ESonkiU?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/KJSu_8cialA?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/rYcMuSEZOBA?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
<iframe width="560" height="315" src="https://www.youtube.com/embed/bSsH_uCwNbQ?rel=0" title="Youtube video - Karan raj" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
</div>
