頁面loading效果實現程式碼
阿新 • • 發佈:2018-11-05
有些頁面載入起來比較慢,為了加強使用者體驗效果,所以一般都會做一個頁面載入等待的提示,頁面載入完成後消失。
下面提供一個可以拿來即用的方案。
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
.index-loading {
position: fixed;
z-index : 100;
width: 100px;
height: 100px;
left: 50%;
top: 50%;
margin-left: -50px;
margin-top: -50px;
-webkit-animation: progressRotate 0.6s linear infinite;
animation: progressRotate 0.6s linear infinite;
}
@-webkit-keyframes progressRotate {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
@keyframes progressRotate {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform : rotate(360deg);
}
}
</style>
</head>
<body>
<img class="index-loading" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/NlyAAAAAXNSR0IArs4c6QAACahJREFUaAXtW2twU8cV3rNXsi3bGNuSwElbsGUnDk3TIRjS5t02mUmnTUmACaQvoBlIO31Pm+AHMLlpeViEoU0yTVNC2mnLTBkC7YQ24EkTStPMpO2EtIxLEohtmYSEhyQ/ILUsS7rbbyWucvW4kmxkI81Uf3b3nHPPPd89u2d3z66ITcLvalWU/Dfou55rrEVj4mN4xRwmmJMxshOxSsHEGOpBJsQQI/KQYH2gdVss9PK1cx1HnllKkUkwK6qS8qX4+m3CdvqM/x6AWMJIfEYIVjkR3cTovCD2HD7Irgqb/cBRlfBx8ve7aMBXtQ3WB0XoARj4FSHE9PyZJjXRABE9ofDSx3o2T/PmQ/eEAc/p8F4WiLD16I6r0B2t+TAmg44APP+EUs5/1KPaz2WQy8oaN2B4kVxtvlXQ/Ej+PZrV3tOk8DWezY7fZpU0ERgX4KvV4dqRkbHd8OhtJvrMyUQaY2IQ3XQUQpdhrHNz4cwcBL69023WVf9Wa4YyS6ZycwYcHatauAtgm1PVJFGIjkLxASb481QS6bdZSv3/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