我的css渐变动画正在运行,除了所有部分都在变化,而不是像www.verily.com这样从头到尾运行,这是我试过的,
.animated {
-webkit-animation: animated1 20s infinite;
animation: animated1 20s infinite;
}
@-webkit-keyframes animated1 {
0%,
100% {
background-color: #2878ff
}
50% {
background-color: #ff1643
}
}
@keyframes animated1 {
0%,
100% {
background-color: #2878ff
}
50% {
background-color: #ff1643
}
}
答案 0 :(得分:1)
以下是制作linear-gradient
body {
background: linear-gradient(270deg, #f51313, #fbf708);
background-size: 400% 400%;
-webkit-animation: anim 10s ease infinite;
animation: anim 10s ease infinite;
}
@-webkit-keyframes anim {
0%, 100% {
background-position: 0% 50%
}
50% {
background-position: 100% 50%
}
}
@keyframes anim {
0%, 100% {
background-position: 0% 50%
}
50% {
background-position: 100% 50%
}
}
答案 1 :(得分:1)
实际上,真正实现其效果的方式是通过动画制作图像。
* {
box-sizing: border-box;
}
body{
position: relative;
overflow: hidden;
min-height: 100vh;
}
.verily-hero-image-gradient{
background-image: url(//verily.com/img/gradient-loop.png);
background-size: 100% 100%;
animation: hero-gradient-loop 20s infinite;
display: block;
height: 1000%;
position: fixed;
left: 0;
opacity: 1;
top: 0;
width: 100%;
z-index: -1;
}
@keyframes hero-gradient-loop{
0%{
-webkit-transform:translate3d(0,0,0);
transform:translate3d(0,0,0);
}
100%{
-webkit-transform:translate3d(0,-50%,0);
transform:translate3d(0,-50%,0);
}
}
<div class="verily-hero-image-gradient"></div>