【发布时间】:2022-09-22 20:50:09
【问题描述】:
我正在做一个文本漂浮在正弦波旋转的波浪上的动画。我得到了正弦曲线本身。但是我在平滑旋转文本中的字母以使它们平滑地相互跟随时卡住了,如下面的示例所示。 文字本身上下浮动,转动时字母转动不顺畅。告诉我如何实现正确的字母轮换。
html,
body{
margin: 0;
padding: 0;
background-color: black;
font-family: Arial, Helvetica, sans-serif;
}
.text-anim-wrapper{
position: relative;
overflow: hidden;
height: 150px;
}
.text-anim{
position: absolute;
left: calc(100% + 200px);
width: 20px;
font-size: 24px;
color: white;
font-weight: bold;
transform: rotate(10deg);
animation: flight-right-to-left 6s linear infinite, curve 6s ease infinite, curve-rotate 6s ease infinite;
}
.text-anim:nth-child(2) {
animation-delay: .1s;
}
.text-anim:nth-child(3) {
animation-delay: .2s;
}
.text-anim:nth-child(4) {
animation-delay: .3s;
}
.text-anim:nth-child(5) {
animation-delay: .4s;
}
.text-anim:nth-child(6) {
animation-delay: .5s;
}
.text-anim:nth-child(7) {
animation-delay: .6s;
}
.text-anim:nth-child(8) {
animation-delay: .7s;
}
.text-anim:nth-child(9) {
animation-delay: .8s;
}
@keyframes flight-right-to-left {
0%{
left: 100%;
}
100%{
left: -20px;
}
}
@keyframes curve {
0%{
top: 50px;
}
20%{
top: 0;
}
50%{
top: 80px;
}
85%{
top: 0;
}
100%{
top: 50px;
}
}
@keyframes curve-rotate {
25%{
transform: rotate(-10deg);
}
50%{
transform: rotate(0deg);
}
75%{
transform: rotate(10deg);
}
100%{
transform: rotate(-10deg);
}
}
<div class=\"text-anim-wrapper\">
<div class=\"text-anim\">V</div>
<div class=\"text-anim\">I</div>
<div class=\"text-anim\">C</div>
<div class=\"text-anim\">T</div>
<div class=\"text-anim\">O</div>
<div class=\"text-anim\">R</div>
<div class=\"text-anim\">I</div>
<div class=\"text-anim\">N</div>
<div class=\"text-anim\">E</div>
</div>
预期结果example
标签: html css animation text css-animations