【发布时间】:2020-10-05 06:41:59
【问题描述】:
我正在尝试使用 CSS 动画来创建光源指向对象、投射阴影并围绕它做圆周运动的效果。我在下面创建了一个 sn-p 来显示我到目前为止的位置。
有点接近,但目前(因为我只有 4 个关键帧)就像光源沿着方形路径移动。我希望它看起来像沿着圆形路径移动。
我能想到的唯一解决方案是添加更多关键帧并创建(为简单起见)十二边形路径,但有更简单的解决方案吗?有没有一种计时功能可以让我缓和它进入更平滑的路径?或者我可以使用某种 Sass 函数来自动计算中间关键帧吗?
我应该注意到,一旦我开始使用 box-shadows,我还想将相同的方法应用于 text-shadows。
.container {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100vh;
}
.circle {
width: 200px;
height: 200px;
border-radius: 100%;
background-color: teal;
box-shadow: 50px 50px 5px darkgrey;
animation: orbit-shadow 5s linear infinite;
}
@keyframes orbit-shadow {
0% {
box-shadow: 50px 50px 5px darkgrey;
}
25% {
box-shadow: -50px 50px 5px darkgrey;
}
50% {
box-shadow: -50px -50px 5px darkgrey;
}
75% {
box-shadow: 50px -50px 5px darkgrey;
}
1000% {
box-shadow: 50px 50px 5px darkgrey;
}
}
<div class="container">
<div class="circle"></div>
</div>
【问题讨论】:
标签: css css-animations