用html和js写一个loading页面
时间: 2023-12-19 17:07:26 浏览: 30
<!DOCTYPE html>
<html>
<head>
<title>Loading Page</title>
<style>
body {
margin: 0;
padding: 0;
background-color: #f2f2f2;
font-family: Arial, sans-serif;
text-align: center;
}
h1 {
margin-top: 100px;
font-size: 36px;
color: #333;
}
#loader {
margin-top: 50px;
border: 16px solid #f3f3f3;
border-top: 16px solid #3498db;
border-radius: 50%;
width: 120px;
height: 120px;
animation: spin 2s linear infinite;
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
</style>
</head>
<body>
<h1>Loading...</h1>
<div id="loader"></div>
<script>
window.addEventListener("load", function() {
document.body.style.overflow = "hidden";
document.querySelector("#loader").style.display = "none";
document.body.style.overflow = "auto";
});
</script>
</body>
</html>