我想爲我的項目製作一個JavaScript(JavaScript動畫)作爲網站的預加載器。沿此線爲HTML頁面製作Javascript預加載器
東西: http://soulwire.github.io/Plasmatic-Isosurface/
我想這是第一次運行,直到我的網頁元素被下載之後,它應該關閉,並顯示完全加載頁面
是這可能嗎?
感謝
下面是一個示例HTML代碼我想測試它
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Javascript preloader</title>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<div class="preloader"></div>
<canvas id='canvas'></canvas>
<script src="js/index.js"></script>
<img src="https://wallpaperscraft.com/image/stars_sky_shore_84534_1920x1080.jpg" alt="safe"></img>
</body>
</html>
**編輯給您一個div需要爲你的動畫代碼道歉
<!DOCTYPE html>
<html >
<head>
<meta charset="UTF-8">
<title>Preloader Testing</title>
<style>
.preloader{
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: 1000;
}
</style>
<link rel="stylesheet" href="css/style.css">
</head>
<body>
<canvas class="preloader" id='canvas'></canvas>
<script src="js/index.js"></script>
<img src="https://wallpaperscraft.com/image/stars_sky_shore_84534_1920x1080.jpg" alt="safe"></img>
</body>
<script>
//after window is loaded completely
window.onload = function(){
//hide the preloader
document.querySelector(".preloader").style.display = "none";
}
</script>
</html>
https://ihatetomatoes.net/create-custom-preloading-screen/ – Nezir
這是適用於CSS動畫,而不是一個javascript一。如果我錯了,請糾正我(並對不起) –