我正在制作一个网站,虽然这增加了一个飞溅的屏幕将是很好的,并使网站更时尚。我为它做了代码,但是问题是,文本看起来还可以,但是文本不会在设定的时间后消失--1秒--它不会消失,我通常会重新检查并没有发现错误,当我运行它时,它会工作,不会出现错误。
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 class="splash">
<h1 class="fade-out">Welcome to My Website!</h1>
</div>
<ul class="navbar">
<li class="navbar-item left"><a class="no-style-link" href="/">Karan raj</a></li>
<li class="navbar-item right"><a class="no-style-link" href="/">Home</a></li>
<li class="navbar-item right"><a class="no-style-link" href="/about">About</a></li>
<li class="navbar-item right"><a class="no-style-link" href="/contact">Contact</a></li>
</ul>
<div class="main-content">
<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 class="ytvidcollection">
<iframe class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="copyright">© Copyright 2022 <a href="https://jothin.tech" id="Jothin-kumar">Jothin kumar</a></div>
</body>
</html>
发布于 2022-01-18 14:22:17
使用jquery,
document.addEventListener('DOMContentLoaded', (e)=>{
setTimeout(()=>{
$(".splash").css("display", "none");
}, 2000);
})发布于 2022-01-18 14:23:10
您正在添加一个“display”类,但是CSS中没有包含这个类。
只要将它添加到CSS中,就可以修复它:
.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 class="splash">
<div>Welcome to My Website!</div>
</div>
<ul class="navbar">
<li class="navbar-item left"><a class="no-style-link" href="/">Karan raj</a></li>
<li class="navbar-item right"><a class="no-style-link" href="/">Home</a></li>
<li class="navbar-item right"><a class="no-style-link" href="/about">About</a></li>
<li class="navbar-item right"><a class="no-style-link" href="/contact">Contact</a></li>
</ul>
<div class="main-content">
<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 class="ytvidcollection">
<iframe class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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>
发布于 2022-01-19 03:27:35
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 class="splash">
<div>Welcome to My Website!</div>
</div>
<ul class="navbar">
<li class="navbar-item left"><a class="no-style-link" href="/">Karan raj</a></li>
<li class="navbar-item right"><a class="no-style-link" href="/">Home</a></li>
<li class="navbar-item right"><a class="no-style-link" href="/about">About</a></li>
<li class="navbar-item right"><a class="no-style-link" href="/contact">Contact</a></li>
</ul>
<div class="main-content">
<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 class="ytvidcollection">
<iframe class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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 class="ytvid" 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>
https://stackoverflow.com/questions/70756835
复制相似问题