gpt4 book ai didi

html - 使用 CSS3 制作按钮弹跳

转载 作者:太空狗 更新时间:2023-10-29 15:34:50 26 4
gpt4 key购买 nike

我正在尝试使用 CSS3 使这个按钮弹跳

.order {
position: absolute;
top: 50px;
left: 50px;
width: 75px;
line-height: 75px;
text-align:center;
opacity: 1;
background: green;
color:#fff;
border-radius:50%;
}
<div class="order">Order</div>

我希望它朝屏幕(在 Z 轴上)上下弹跳。

最佳答案

您可以使用关键帧动画来设置按钮的缩放比例并使其反弹:

.order {
position: absolute;
top: 50px;
left: 50px;
width: 75px;
line-height: 75px;
text-align:center;
opacity: 1;
background: green;
color:#fff;
border-radius:50%;
-webkit-animation: bounce .3s infinite alternate;
-moz-animation: bounce .3s infinite alternate;
animation: bounce .3s infinite alternate;
}
@-webkit-keyframes bounce {
to { -webkit-transform: scale(1.2); }
}
@-moz-keyframes bounce {
to { -moz-transform: scale(1.2); }
}
@keyframes bounce {
to { transform: scale(1.2); }
}
<div class="order">Order</div>

迭代次数:

如果你想在多次“反弹”后停止动画,你可以使用animation-iteration-count(使用偶数次迭代否则动画会在最后停止):

.order {
position: absolute;
top: 50px;
left: 50px;
width: 75px;
line-height: 75px;
text-align:center;
opacity: 1;
background: green;
color:#fff;
border-radius:50%;
-webkit-animation: bounce .3s infinite alternate;
-moz-animation: bounce .3s infinite alternate;
animation: bounce .3s infinite alternate;
-webkit-animation-iteration-count: 8;
-moz-animation-iteration-count: 8;
animation-iteration-count: 8;
}
@-webkit-keyframes bounce {
to { -webkit-transform: scale(1.2); }
}
@-moz-keyframes bounce {
to { -moz-transform: scale(1.2); }
}
@keyframes bounce {
to { transform: scale(1.2); }
}
<div class="order">Order</div>

关于html - 使用 CSS3 制作按钮弹跳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29005916/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com