HTML, CSS, JS 实现弹窗 Loading 效果
<div id='loading'>
<div class='spinner'></div>
</div>
<style>
#loading {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 9999;
display: none;
}
.spinner {
border: 4px solid rgba(255, 255, 255, 0.3);
border-top: 4px solid #fff;
border-radius: 50%;
width: 40px;
height: 40px;
margin: auto;
animation: spin 0.8s linear infinite;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
<script>
function showLoading() {
document.getElementById('loading').style.display = 'block';
}
function hideLoading() {
document.getElementById('loading').style.display = 'none';
}
</script>
<p>调用 showLoading() 函数显示 Loading 弹窗,调用 hideLoading() 函数隐藏 Loading 弹窗。</p>
原文地址: https://www.cveoy.top/t/topic/mIWH 著作权归作者所有。请勿转载和采集!