【发布时间】:2025-12-05 06:40:02
【问题描述】:
我已经阅读了一些关于如何实现流畅的 CSS 动画的博客,例如 here。
我实际上是在尝试实现类似于下面的红色圆圈比例动画:
但是动画没有我想要的那么流畅。
这是我的Jsfiddle
body,
html {
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
overflow: hidden;
}
.circle {
position: relative;
display: flex;
align-items: center;
justify-content: center;
}
.circle .first,
.circle .second {
width: 2200px;
height: 2200px;
position: absolute;
}
.circle .first {
animation: scale 2s cubic-bezier(0.5, 0.01, 0, 0.08) infinite;
opacity: 0;
}
.circle .second {
animation: scale-second 1s cubic-bezier(0.5, 0.01, 0, 0.08) infinite;
animation-delay: 7s;
opacity: 0
}
@keyframes scale {
from {
transform: scale(0);
opacity: 1;
}
to {
transform: scale(1.5);
opacity: 1;
}
}
@keyframes scale-second {
from {
transform: scale(0);
opacity: 1;
}
to {
transform: scale(1.2);
opacity: 1;
}
}
<body>
<div class="circle">
<svg class="first" viewBox="0 0 100 100" fill="#ff948d">
<circle cx="50" cy="50" r="50"></circle>
</svg>
<svg class="second" viewBox="0 0 100 100" fill="white">
<circle cx="50" cy="50" r="50"></circle>
</svg>
</div>
</body>
你可以看到全屏时动画不流畅。
【问题讨论】:
-
您好,您有基本动画的网址吗?
-
你是指附加的 gif 吗? @t3__rry
-
是的,这个。顺便说一句,您可以先将
will-change: transform规则添加到.circle以使其成为GPU 加速css-tricks.com/almanac/properties/w/will-change
标签: javascript css animation css-animations transform