您可以使用:before
伪元素在按钮下创建另一个矩形并用于transform
在单击时对其进行缩放。:active
您可以使用click
事件代替 css状态。单击元素后,您需要单击其他元素以删除活动状态并在单击时再次查看效果。
button {
padding: 10px 25px;
background: red;
color: white;
margin: 50px;
border: none;
position: relative;
outline: none;
}
button:before {
content: '';
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 100%;
background: black;
z-index: -1;
}
button:focus:before {
transform: scale(2);
transition: all 0.4s linear;
opacity: 0;
}
<button>Click</button>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句