2017-04-12 94 views

回答

1

你应该学会检查并获得

@keyframes bgcolor { 
 
    0% { 
 
     background-color: #45a3e5 
 
    } 
 

 
    30% { 
 
     background-color: #66bf39 
 
    } 
 

 
    60% { 
 
     background-color: #eb670f 
 
    } 
 

 
    90% { 
 
     background-color: #f35 
 
    } 
 

 
    100% { 
 
     background-color: #864cbf 
 
    } 
 
} 
 

 
body { 
 
    -webkit-animation: bgcolor 20s infinite; 
 
    animation: bgcolor 10s infinite; 
 
    -webkit-animation-direction: alternate; 
 
    animation-direction: alternate; 
 
}

+0

谢谢,我试过检查元素,但不知道哪个文件是在。 – PlanetVaster

+0

@PlanetVaster注意到这个解决方案交替颜色顺序,你可能会很好。例如,如果颜色顺序是红色,黄色和蓝色,则按以下顺序运行颜色:红色,黄色,蓝色,黄色,红色。默认情况下会做红色,黄色,蓝色,红色,黄色,蓝色。 – hungerstar

0

你真的没有向我们展示任何你想要的东西。但我是一个好人,我知道你会学习的榜样:

body { 
    animation: colorchange 10s infinite; 
} 

@keyframes colorchange 
{ 
    0% {background: red;} 
    25% {background: yellow;} 
    50% {background: blue;} 
    75% {background: green;} 
    100% {background: red;} 
} 

根据需要修改。显然,将body更改为您的div封套与背景颜色无关。

+0

对不起,我可以得到有用的东西,但看起来不正确,我忘了发布它。 – PlanetVaster

0
/* The animation code */ 
@keyframes example { 
    0% {background-color: red;} 
    33% {background-color: yellow;} 
    66% {background-color: blue;} 
    100% {background-color: red;} 
} 

/* The element to apply the animation to */ 
div { 
    width: 100px; 
    height: 100px; 
    background-color: red; 
    animation-name: example; 
    animation-duration: 10s; 
    animation-iteration-count: infinite; 
} 
0

body { 
 
    animation: 10000ms ease-in-out infinite color-change; 
 
} 
 

 
@keyframes color-change { 
 
    0% { 
 
    background-color: teal; 
 
    } 
 
    20% { 
 
    background-color: gold; 
 
    } 
 
    40% { 
 
    background-color: indianred; 
 
    } 
 
    60% { 
 
    background-color: violet; 
 
    } 
 
    80% { 
 
    background-color: green; 
 
    } 
 
    100% { 
 
    background-color: teal; 
 
    } 
 
}

+0

这显然有效。为什么downvote? – hungerstar

+0

我不知道为什么,我没有倒下它 – PlanetVaster