@import url(http://fonts.googleapis.com/css?family=Play:400,700);
* {
box-sizing: border-box;
}
body {
background-color: #222;
font-family: "Play";
}
h1 {
font-size: 2rem;
color: #FFF;
text-align: center;
text-transform: uppercase;
}
.smart-glass {
position: absolute;
margin: auto;
left: 0;
top: 0;
right: 0;
bottom: 0;
width: 288px;
height: 388px;
}
.logo {
width: 288px;
height: 288px;
position: relative;
}
.circle {
padding: 20px;
border: 6px solid transparent;
border-top-color: #40A800;
border-radius: 50%;
width: 100%;
height: 100%;
animation: connect 2.5s linear infinite;
}
.xbox {
background: #FFF;
width: 80px;
height: 80px;
border-radius: 100%;
overflow: hidden;
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
margin: auto;
}
.xbox:after, .xbox:before {
content: "";
display: block;
border-top: 10px solid #222;
border-radius: 50%;
height: 90%;
width: 120%;
transform: rotate(-45deg);
position: absolute;
right: -30%;
top: 15%;
}
.xbox:before {
left: -30%;
transform: rotate(45deg);
}
.loading-text {
text-transform: uppercase;
color: #FFF;
text-align: center;
margin: 10px 0;
font-size: 1.4rem;
}
@keyframes connect {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(-360deg);
}
}

<div class="smart-glass">
<h1>Xbox</h1>
<div class="logo">
<div class="circle">
<div class="circle">
<div class="circle">
</div>
</div>
</div>
<div class="hold-x">
<div class="xbox"></div>
</div>
</div>
<div class="loading-text">
Loading...
</div>
</div>
&#13;
嗯,我在一个网站上看到了这个加载动画,我打算将它插入到我的代码中,但我遇到的问题是如何在页面完成加载后停止动画。任何帮助都将受到高度赞赏
答案 0 :(得分:2)
你可以这样做:
$('.smart-glass').css('display','none');
这里我设置间隔隐藏。经过一段时间后隐藏起来。如果要隐藏动画,可以使用上面的代码。
setInterval(function(){ $('.smart-glass').fadeOut();
$('body').css('background', 'transparent');
}, 5000);
&#13;
@import url(http://fonts.googleapis.com/css?family=Play:400,700);
* {
box-sizing: border-box;
}
body {
background-color: #222;
font-family: "Play";
}
h1 {
font-size: 2rem;
color: #FFF;
text-align: center;
text-transform: uppercase;
}
.smart-glass {
position: absolute;
margin: auto;
left: 0;
top: 0;
right: 0;
bottom: 0;
width: 288px;
height: 388px;
}
.logo {
width: 288px;
height: 288px;
position: relative;
}
.circle {
padding: 20px;
border: 6px solid transparent;
border-top-color: #40A800;
border-radius: 50%;
width: 100%;
height: 100%;
animation: connect 2.5s linear infinite;
}
.xbox {
background: #FFF;
width: 80px;
height: 80px;
border-radius: 100%;
overflow: hidden;
position: absolute;
top: 0;
right: 0;
left: 0;
bottom: 0;
margin: auto;
}
.xbox:after, .xbox:before {
content: "";
display: block;
border-top: 10px solid #222;
border-radius: 50%;
height: 90%;
width: 120%;
transform: rotate(-45deg);
position: absolute;
right: -30%;
top: 15%;
}
.xbox:before {
left: -30%;
transform: rotate(45deg);
}
.loading-text {
text-transform: uppercase;
color: #FFF;
text-align: center;
margin: 10px 0;
font-size: 1.4rem;
}
@keyframes connect {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(-360deg);
}
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="smart-glass">
<h1>Xbox</h1>
<div class="logo">
<div class="circle">
<div class="circle">
<div class="circle">
</div>
</div>
</div>
<div class="hold-x">
<div class="xbox"></div>
</div>
</div>
<div class="loading-text">
Loading...
</div>
</div>
&#13;
答案 1 :(得分:1)
您可以先fadeOut
动画部分,然后remove
它的DOM内容
$(".smart-glass").fadeOut(3000,function(){ // Will fade out in 3 secs
$(".smart-glass").remove(); // animated part will be removed from DOM
$('body').css('background-color',"#fff"); // background will be changed to white
})
})
答案 2 :(得分:1)
为什么不为此使用if语句?似乎完全适合这种情况。我一直在寻找相同的东西,找不到任何容易且真正可行的东西,所以我只是将加载器放入if语句中,如下所示。适用于我的PHP代码。
<?php
if (!isset($_SESSION['something'])) {
?>
<div>
<div>
<div class='loader'></div>
<br>
<div> Redirecting...</div>
</div>
</div>
<?php
echo '<meta http-equiv=REFRESH CONTENT=3;url=url>';
} else {
?>
答案 3 :(得分:0)
如果您希望动画在页面加载时停止,请使用以下JQuery代码:
$(window).on('load', function() {
$('.smart-glass').fadeOut(3000);
});
这是一个JQuery函数,它使不透明度从1
到0
,然后在3秒(3000毫秒)内从display: none
变为不透明。因此,到达display: none
后,您将看不到它,并且页面继续正常运行。您也可以使用输入和表格,它不会受到影响。
我希望这会有所帮助。