CSS 实现防止按钮重复点击
代码如下:复制直接使用
body {
display: grid;
place-content: center;
height: 100vh;
margin: 0;
gap: 15px;
background: #f1f1f1;
user-select: none;
}
button {
user-select: none;
}
.throttle {
animation: throttle 2s step-end forwards;
}
.throttle:active {
animation: none;
}
@keyframes throttle {
from {
pointer-events: none;
opacity: .5;
}
to {
pointer-events: all;
opacity: 1;
}
}
效果:
作者:freddyhuang
出处:https://www.cnblogs.com/freddyhuang
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。