我为我的网站制作了一个加载屏幕,但有点不知道如何将其附加到网站上。
我必须遵循以下代码:
body {
margin: 0;
padding: 0;
background: black;
}
.loading {
width: 200px;
height: 200px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.loading h1 {
color: #4df3ff;
text-align: center;
}
.loading .circle {
border-radius: 50%;
border-left: 4px solid;
border-right: 4px solid;
border-top: 4px solid transparent !important;
border-bottom: 4px solid transparent;
position: absolute;
top: 24%;
left: 50%;
transform: translate(-50%, -50%);
animation: rounds 2s infinite;
}
.loading .color1 {
border-color: #45f3ff;
width: 220px;
height: 220px;
}
.loading .color2 {
border-color: #00474d;
width: 200px;
height: 200px;
animation-delay: 0.2s
}
.loading .color3 {
border-color: #33f1ff;
width: 180px;
height: 180px;
animation-delay: 0.4s
}
.loading .color4 {
border-color: #005f66;
width: 160px;
height: 160px;
animation-delay: 0.6s
}
@keyframes rounds {
0% {
transform: translate(-50%, -50%) rotate(0deg);
}
50% {
transform: translate(-50%, -50%) rotate(-180deg);
}
100% {
transform: translate(-50%, -50%) rotate(0deg);
}
}
<div class="loading">
<h1>Loading..!</h1>
<div class="circle color1"></div>
<div class="circle color2"></div>
<div class="circle color3"></div>
<div class="circle color4"></div>
</div>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less
normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum'
will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
</p>
答案 0 :(得分:1)
我会将您的装载机放在包装纸中,使其适合整个窗口,然后在一定时间后将其隐藏。
setTimeout(() => {
document.querySelector('#loading_wrapper').style.display = 'none';
}, 3000);
#loading_wrapper {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background-color: black;
}
.loading {
width: 200px;
height: 200px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.loading h1 {
color: #4df3ff;
text-align: center;
}
.loading .circle {
border-radius: 50%;
border-left: 4px solid;
border-right: 4px solid;
border-top: 4px solid transparent !important;
border-bottom: 4px solid transparent;
position: absolute;
top: 24%;
left: 50%;
transform: translate(-50%, -50%);
animation: rounds 2s infinite;
}
.loading .color1 {
border-color: #45f3ff;
width: 220px;
height: 220px;
}
.loading .color2 {
border-color: #00474d;
width: 200px;
height: 200px;
animation-delay: 0.2s
}
.loading .color3 {
border-color: #33f1ff;
width: 180px;
height: 180px;
animation-delay: 0.4s
}
.loading .color4 {
border-color: #005f66;
width: 160px;
height: 160px;
animation-delay: 0.6s
}
@keyframes rounds {
0% {
transform: translate(-50%, -50%) rotate(0deg);
}
50% {
transform: translate(-50%, -50%) rotate(-180deg);
}
100% {
transform: translate(-50%, -50%) rotate(0deg);
}
}
<div id="loading_wrapper">
<div class="loading">
<h1>Loading..!</h1>
<div class="circle color1"></div>
<div class="circle color2"></div>
<div class="circle color3"></div>
<div class="circle color4"></div>
</div>
</div>
<p>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has
survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing
software like Aldus PageMaker including versions of Lorem Ipsum. It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less
normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum'
will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
</p>