gpt4 book ai didi

html - 如何为输入占位符制作弹跳效果?

转载 作者:太空宇宙 更新时间:2023-11-04 06:08:30 25 4
gpt4 key购买 nike

如何为输入占位符制作弹跳效果?我的输入占位符需要 bounceIn 效果。如何为这个占位符设置动画呢?现在我的动画不工作了。

@keyframes bounceIn {
from,
20%,
40%,
60%,
80%,
to {
-webkit-animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
}

0% {
opacity: 0;
-webkit-transform: scale3d(0.3, 0.3, 0.3);
transform: scale3d(0.3, 0.3, 0.3);
}

20% {
-webkit-transform: scale3d(1.1, 1.1, 1.1);
transform: scale3d(1.1, 1.1, 1.1);
}

40% {
-webkit-transform: scale3d(0.9, 0.9, 0.9);
transform: scale3d(0.9, 0.9, 0.9);
}

60% {
opacity: 1;
-webkit-transform: scale3d(1.03, 1.03, 1.03);
transform: scale3d(1.03, 1.03, 1.03);
}

80% {
-webkit-transform: scale3d(0.97, 0.97, 0.97);
transform: scale3d(0.97, 0.97, 0.97);
}

to {
opacity: 1;
-webkit-transform: scale3d(1, 1, 1);
transform: scale3d(1, 1, 1);
}
}

.search {
padding: 10px;
}

.search:focus::placeholder {
animation: bounceIn 2s infinite;
}
<input class="search" type="text" name="Search" value="" placeholder="Search...">

最佳答案

您只需要从以下位置删除 ::placeholder:

.search:focus::placeholder {
animation: bounceIn 2s infinite;
}

此外,您可能会发现最好不要无限重复动画。

@keyframes bounceIn {
from,
20%,
40%,
60%,
80%,
to {
-webkit-animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
animation-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
}

0% {
opacity: 0;
-webkit-transform: scale3d(0.3, 0.3, 0.3);
transform: scale3d(0.3, 0.3, 0.3);
}

20% {
-webkit-transform: scale3d(1.1, 1.1, 1.1);
transform: scale3d(1.1, 1.1, 1.1);
}

40% {
-webkit-transform: scale3d(0.9, 0.9, 0.9);
transform: scale3d(0.9, 0.9, 0.9);
}

60% {
opacity: 1;
-webkit-transform: scale3d(1.03, 1.03, 1.03);
transform: scale3d(1.03, 1.03, 1.03);
}

80% {
-webkit-transform: scale3d(0.97, 0.97, 0.97);
transform: scale3d(0.97, 0.97, 0.97);
}

to {
opacity: 1;
-webkit-transform: scale3d(1, 1, 1);
transform: scale3d(1, 1, 1);
}
}

.search {
padding: 10px;
}

.search:focus {
animation: bounceIn 2s infinite;
}
<h3>Click in input field to trigger animation</h3>
<input class="search" type="text" name="Search" value="" placeholder="Search...">

关于html - 如何为输入占位符制作弹跳效果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56614697/

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