【typecho】给 typecho 主题添加加载动画

在网络加载慢的情况下,有个加载动画,体验会更好。

donghua.jpg

废话不多说,正式开始。

00

全局引入jQuery,在</head>前面添加以下代码:

<script type="text/javascript" src="http://apps.bdimg.com/libs/jquery/1.6.4/jquery.min.js
"></script>

01

header.php<body> 后面添加以下代码:

<!-- 加载动画显示代码开始 -->
<div id="loading">
<div id="loading-one"></div>
<div class="spinner">
    <div class="rect1"></div>
    <div class="rect2"></div>
    <div class="rect3"></div>
    <div class="rect4"></div>
    <div class="rect5"></div>
</div>
</div>
<!-- 加载动画显示代码结束 -->

02

footer.php</body>前面添加以下代码:

<!-- 加载动画 -->
<script>
jQuery(window).load(function() {
    jQuery("#loading").fadeOut(500);
});
</script>
<!-- 加载动画 -->

03

style.css中加入样式代码:

/* 以下是加载动画样式 */
#loading {
    position: fixed !important;
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    z-index: 999;
    background: #000;
    opacity: 0.7;
    filter: alpha(opacity=70);
    font-size: 14px;
    line-height: 20px
}
#loading-one {
    color: #fff;
    position: absolute;
    top: 50%;
    left: 50%;
    margin: 50px 0 0 -80px;
    padding: 3px 10px
}
.spinner {
    position: absolute;
margin-right: 500px;
    top: 50%;
    left: 50%;
  width: 50px;
  height: 60px;
    margin: 0 0 0 -20px;
  font-size: 10px;
}

.spinner > div {
  background-color: #67CF22;
  height: 100%;
  width: 6px;
  display: inline-block;

  -webkit-animation: stretchdelay 1.2s infinite ease-in-out;
  animation: stretchdelay 1.2s infinite ease-in-out;
}

.spinner .rect2 {
  -webkit-animation-delay: -1.1s;
  animation-delay: -1.1s;
}

.spinner .rect3 {
  -webkit-animation-delay: -1.0s;
  animation-delay: -1.0s;
}

.spinner .rect4 {
  -webkit-animation-delay: -0.9s;
  animation-delay: -0.9s;
}

.spinner .rect5 {
  -webkit-animation-delay: -0.8s;
  animation-delay: -0.8s;
}

@-webkit-keyframes stretchdelay {
  0%, 40%, 100% { -webkit-transform: scaleY(0.4) }
  20% { -webkit-transform: scaleY(1.0) }
}

@keyframes stretchdelay {
  0%, 40%, 100% {
    transform: scaleY(0.4);
    -webkit-transform: scaleY(0.4);
  }  20% {
    transform: scaleY(1.0);
    -webkit-transform: scaleY(1.0);
  }
}
-------- 本文结束  感谢阅读 --------
0%