如何让动画渐进流畅而不是一步一步的?
如何让动画渐进流畅而不是一步一步的? 我不能使用 :hover 因为它是一个在按钮中带有 onclick 事件的动画。 html只是一个带有添加类的功能的按钮:change来启动动画。 它还有一个功能来获取鼠标位置,用于制作渐变效果。 这是CSS:
.bg {
background: url(../images/meow.jpg);
background-position: center;
background-repeat: no-repeat;
background-size: cover;
height: 100vh;
}
#root {
cursor: url("../images/cursor.png"), auto;
--X: 40vh;
--Y: 45vh;
}
#root::before {
animation-name: example;
animation-duration: 2s;
content: "";
display: block;
height: 100%;
width: 100%;
position: fixed;
background: black;
pointer-events: none;
}
#root.change::before {
animation: gradient 5s ease-in-out forwards;
}
@keyframes gradient {
0% {
background: radial-gradient(
circle 1vma
x at var(--X) var(--Y),
rgba(0, 0, 0, 0) 0%,
rgba(0, 0, 0, 0.4) 80%,
rgba(0, 0, 0, 0.90) 100%);
}
100% {
background: radial-gradient(
circle 10vmax at var(--X) var(--Y),
rgba(0, 0, 0, 0) 0%,
rgba(0, 0, 0, 0.8) 80%,
rgba(0, 0, 0, 0.90) 100%);
}
How can I make the animation gradual and smooth and not step by step?
I cant use :hover because its an animation with an onclick event in a button.
The html is only a button with a function that adds the class: change to start the animation.
It has too a function to take the mouse position that it uses to make de gradient effect.
This is the css:
.bg {
background: url(../images/meow.jpg);
background-position: center;
background-repeat: no-repeat;
background-size: cover;
height: 100vh;
}
#root {
cursor: url("../images/cursor.png"), auto;
--X: 40vh;
--Y: 45vh;
}
#root::before {
animation-name: example;
animation-duration: 2s;
content: "";
display: block;
height: 100%;
width: 100%;
position: fixed;
background: black;
pointer-events: none;
}
#root.change::before {
animation: gradient 5s ease-in-out forwards;
}
@keyframes gradient {
0% {
background: radial-gradient(
circle 1vma
x at var(--X) var(--Y),
rgba(0, 0, 0, 0) 0%,
rgba(0, 0, 0, 0.4) 80%,
rgba(0, 0, 0, 0.90) 100%);
}
100% {
background: radial-gradient(
circle 10vmax at var(--X) var(--Y),
rgba(0, 0, 0, 0) 0%,
rgba(0, 0, 0, 0.8) 80%,
rgba(0, 0, 0, 0.90) 100%);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论