2013-04-07 37 views
2

我有一個使用HTML,CSS3和Dart構建的網站。現在,我將如何製作一個預加載器,在頁面的所有內容加載之前運行?如何爲飛鏢中的網頁製作預加載器

我甚至在考慮使用像這樣的:http://cssload.net/ 所以我打開任何建議...

更新: 像這樣的事情,但在DART: http://gayadesign.com/scripts/queryLoader2/ http://www.gayadesign.com/diy/queryloader2-preload-your-images-with-ease/

+0

爲什麼每個人都寫名字飛鏢用大寫字母? – 2013-04-08 10:04:19

回答

0

添加html代碼像這樣在你的html頁面中的body標籤之後.. 選擇你喜歡的任何圖片..

<div id="preloader"> 
    <img id="spinner" src="http://cssload.net/preloaders/circular.gif" alt="" /> 
</div> 

使用此jQuery代碼...

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> 
<script> 
/* the preloader division is visible until the whole page loades and then fades out using this code */ 
$(window).load(function() { 
    $('#preloader').fadeOut(300, function() { 
     $(this).remove(); 
    }); 
}); 
</script> 

然後添加這個CSS代碼

#preloader,#spinner { 
    position:fixed; 
    top:0; left:0; right:0; bottom:0; margin:auto; 
    background:#fff; 
    z-index:9999; 
    overflow:hidden; 
} 

它會工作...

+1

感謝您的回答,但這是jQuery,而不是飛鏢。稍後我會發布我的解決方案 – ThanksBro 2013-05-09 05:45:46