<!DOCTYPE html>
<html>
<head>
	<title>Loading</title>
	<style>
		.loading{
			border: 16px solid #f3f3f3;
			border-top: 16px solid #3498db;
			border-radius: 50%;
			width: 120px;
			height: 120px;
			animation: spin 2s linear infinite;
			display: none;
			position: absolute;
			top: 50%;
			left: 50%;
			transform: translate(-50%, -50%);
		}
		@keyframes spin {
			0% { transform: rotate(0deg); }
			100% { transform: rotate(360deg); }
		}
	</style>
</head>
<body>
	<button onclick="toggleLoading()">Toggle Loading</button>
	<div class="loading" id="loading"></div>
	<script>
		function toggleLoading(){
			var loading = document.getElementById("loading");
			if(loading.style.display == "none"){
				loading.style.display = "block";
			}
			else{
				loading.style.display = "none";
			}
		}
	</script>
</body>
</html>
用html js css写一个loading转圈的效果并且可以用一个button控制其显示和隐藏

原文地址: https://www.cveoy.top/t/topic/bhhs 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录