在网页设计过程中,为按钮添加抖动效果是一种常见的技巧,可以提高用户的体验感。在CSS中,设置按钮点击抖动可以通过使用关键帧动画来实现。首先,我们需要在CSS样式表中定义按钮的基本样式:p { font
p { font-size: 16px; line-height: 1.5; } .btn { display: inline-block; padding: 10px 20px; background-color: #2c3e50; color: #fff; border: none; border-radius: 5px; cursor: pointer; }
@keyframes shake { from, to { transform: translate3D(0, 0, 0); } 10%, 30%, 50%, 70%, 90% { transform: translate3D(-10px, 0, 0); } 20%, 40%, 60%, 80% { transform: translate3D(10px, 0, 0); } } .btn:hover { animation: shake 0.5s; }
<p>请点击下方的按钮测试抖动效果:</p> <button class="btn">点击测试</button>
粉丝
0
关注
0
收藏
0