【发布时间】:2020-06-08 07:08:30
【问题描述】:
我正在尝试为网站创建一个基本的启动画面,但由于某种原因,启动画面上只显示了 1 行文本,而不是 <p> 标记中的剩余文本。这是问题的代码:
Here is a codepen 的问题。
const splash = document.querySelector('.splash');
document.addEventListener('DOMContentLoaded', (e) => {
setTimeout(() => {
splash.classList.add('display-none');
}, 5000);
})
.splash {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: black;
z-index: 9999;
color: white;
text-align: center;
line-height: 90vh;
}
.splash.display-none {
position: fixed;
opacity: 0;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: black;
z-index: 9999;
color: white;
text-align: center;
line-height: 90vh;
transition: 0.5s;
}
@keyframes fadeIn {
to {
opacity: 1;
}
}
.fade-in {
opacity: 0;
animation: fadeIn 1s ease-in forwards;
}
<html>
<head>
<div class="splash">
<p class="fade-in">Hi there! This splashscreen is broken!<br> I can't see this line!<br> I can't see this line either!<br> This line is also missing too!</p>
</div>
<p>hello world</p>
我确信这是一个相对简单的修复,只是在这个问题上有点难过。
【问题讨论】:
-
提示:
line-height
标签: javascript html css splash-screen