漂亮實(shí)用的頁(yè)面loading(加載)封裝代碼
要做一個(gè)異步登錄,打算給用戶做一點(diǎn)提示,所以就網(wǎng)上找了點(diǎn)代碼,自己修改新增了一些,做了一個(gè)html+css+js的功能封裝,以備未來(lái)直接使用。
html
<!-- 緩沖提示條 --> <div class='buffer hidden' id='buffer' > <div class="spinner"> <span class='buffer_tip' id='buffer_tip' >正在登陸</span> <div class="rect1"></div> <div class="rect2"></div> <div class="rect3"></div> <div class="rect4"></div> <div class="rect5"></div> </div> </div> <!-- 緩沖提示條 -->
css
/*緩沖提示條 start*/
.buffer{
background-color: black;
height: 120px;
width: 60%;
margin: auto;
filter: alpha(Opacity=60);
-moz-opacity: 0.6;
opacity: 0.85;
border-radius: 7px;
}
.buffer_tip{
color: wheat;
font-size: 20px;
display: block;
padding-top: 15px;
}
.spinner {
margin: -190% auto;
height: 60px;
text-align: center;
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);
}
}
/*緩沖提示條 end*/
js
/*緩沖進(jìn)度條 start*/
/**
* 顯示loading(加載)動(dòng)畫(huà)
* @param {[type]} tip_text [提示的文字]
* @return {[type]} [description]
*/
function buffer_tip_show(tip_text){
$("#buffer_tip").html(tip_text ? tip_text : '請(qǐng)稍等');
$("#buffer").removeClass("hidden");
}
/**
* 不顯示loading(加載)動(dòng)畫(huà)
* @return {[type]} [description]
*/
function buffer_tip_hidden(){
$("#buffer").addClass("hidden");
}
/*緩沖進(jìn)度條 end*/
如果要顯示或者不顯示動(dòng)畫(huà),直接調(diào)用js函數(shù)就可以啦
// 顯示
buffer_tip_show('正在努力加載中');
// 不顯示
buffer_tip_hidden();
動(dòng)畫(huà)效果無(wú)法截圖額,將就看下

以上所述是小編給大家介紹的漂亮實(shí)用的頁(yè)面loading(加載)封裝代碼,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)腳本之家網(wǎng)站的支持!
相關(guān)文章
原生JS實(shí)現(xiàn)圖片懶加載(lazyload)實(shí)例
圖片懶加載也是比較常見(jiàn)的一種性能優(yōu)化的方法,本篇文章主要介紹了原生JS實(shí)現(xiàn)圖片懶加載(lazyload)實(shí)例,這里整理了詳細(xì)的代碼,有需要的小伙伴可以參考下2017-06-06
JavaScript判斷數(shù)字是否為質(zhì)數(shù)的方法匯總
這篇文章主要介紹了JavaScript判斷數(shù)字是否為質(zhì)數(shù)的方法匯總的相關(guān)資料,非常不錯(cuò)具有參考借鑒價(jià)值,需要的朋友可以參考下2016-06-06
Wordpress ThickBox 添加“查看原圖”效果代碼
上一次修改了點(diǎn)擊圖片動(dòng)作 , 這次添加一個(gè)“查看原圖”的鏈接,點(diǎn)擊后將在一個(gè)新瀏覽器窗口(或Tab)打開(kāi)該圖片的原始鏈接地址。2010-12-12
JS實(shí)現(xiàn)窗口加載時(shí)模擬鼠標(biāo)移動(dòng)的方法
這篇文章主要介紹了JS實(shí)現(xiàn)窗口加載時(shí)模擬鼠標(biāo)移動(dòng)的方法,涉及javascript鼠標(biāo)事件的相關(guān)技巧,需要的朋友可以參考下2015-06-06
微信小程序配置視圖層數(shù)據(jù)綁定相關(guān)示例
這篇文章主要為大家介紹了微信小程序配置視圖層數(shù)據(jù)綁定相關(guān)示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步早日升職加薪<BR>2022-04-04

