Han*_*Sun -1 javascript css html5 css3 html5-canvas
我想要的效果看起来像这样 - >

我想知道在css/js中是否有更简单的方法可以做到这一点?或者是否有任何库来实现它?
如果形状不是直线而是不规则的曲线线怎么办?
不是完全喜欢它但试试这个
.rainbow{
width:200px;
height:20px;
background: -webkit-linear-gradient(left, red,orange,yellow,green,blue,indigo,violet);
background: -moz-linear-gradient(left, red,orange,yellow,green,blue,indigo,violet,red);
background: -o-linear-gradient(left, red,orange,yellow,green,blue,indigo,violet,red);
background: -ms-linear-gradient(left, red,orange,yellow,green,blue,indigo,violet,red);
background: linear-gradient(to right, red,orange,yellow,green,blue,indigo,violet,red);
background-repeat:repeat-x;
-webkit-animation:go 1s linear infinite;
-moz-animation:go 1s linear infinite;
-o-animation:go 1s linear infinite;
-ms-animation:go 1s linear infinite;
animation:go 1s linear infinite;
}
@-webkit-keyframes go{
0%{background-position:0;}
100%{background-position:200px 0;}
}
@-moz-keyframes go{
0%{background-position:0;}
50%{background-position:100px 0;}
100%{background-position:200px 0;}
}
@-o-keyframes go{
0%{background-position:0;}
100%{background-position:200px 0;}
}
@-ms-keyframes go{
0%{background-position:0;}
100%{background-position:200px 0;}
}
@keyframes go{
0%{background-position:0;}
100%{background-position:200px 0;}
}Run Code Online (Sandbox Code Playgroud)
<div class="rainbow"></div>Run Code Online (Sandbox Code Playgroud)
随着宽度减少
.rainbow{
width:200px;
height:5px;
background: -webkit-linear-gradient(left, red,orange,yellow,green,blue,indigo,violet);
background: -moz-linear-gradient(left, red,orange,yellow,green,blue,indigo,violet,red);
background: -o-linear-gradient(left, red,orange,yellow,green,blue,indigo,violet,red);
background: -ms-linear-gradient(left, red,orange,yellow,green,blue,indigo,violet,red);
background: linear-gradient(to right, red,orange,yellow,green,blue,indigo,violet,red);
background-repeat:repeat-x;
-webkit-animation:go 1s linear infinite;
-moz-animation:go 1s linear infinite;
-o-animation:go 1s linear infinite;
-ms-animation:go 1s linear infinite;
animation:go 1s linear infinite;
}
@-webkit-keyframes go{
0%{background-position:0;}
100%{background-position:200px 0;}
}
@-moz-keyframes go{
0%{background-position:0;}
50%{background-position:100px 0;}
100%{background-position:200px 0;}
}
@-o-keyframes go{
0%{background-position:0;}
100%{background-position:200px 0;}
}
@-ms-keyframes go{
0%{background-position:0;}
100%{background-position:200px 0;}
}
@keyframes go{
0%{background-position:0;}
100%{background-position:200px 0;}
}Run Code Online (Sandbox Code Playgroud)
<div class="rainbow"></div>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2155 次 |
| 最近记录: |