I am looking for a CSS
rule which can create a CSS
animation for a button's colored gradient background.
I am just trying to play with it and did this: https://codepen.io/prashant-nadsoftdev/pen/bKzOrB.
.custom-btn {
background: linear-gradient(105deg, #f6d365, #fda085, #f6d365, #ff2400, #e81d1d, #e8b71d, #e3e81d, #1de840, #1ddde8, #2b1de8, #dd00f3, #dd00f3);
background-size: 200% 200%;
-webkit-animation: rainbow 5s ease infinite;
-z-animation: rainbow 5s ease infinite;
-o-animation: rainbow 5s ease infinite;
animation: rainbow 5s ease infinite alternate;
border: 0;
padding: 25px;
font-size: 40px;
color: #fff;
}
@-webkit-keyframes rainbow {
0%{background-position:0% 100%}
100%{background-position:100% 0%}
}
@-moz-keyframes rainbow {
0%{background-position:0% 100%}
100%{background-position:100% 0%}
}
@-o-keyframes rainbow {
0%{background-position:0% 100%}
100%{background-position:100% 0%}
}
@keyframes rainbow {
0%{background-position:0% 100%}
100%{background-position:100% 0%}
}
<body style="text-align:center;">
<button class="custom-btn">My Button</button>
</body>
I need the colors to go one after other in one direction only (left to right). The code I have is close but I still need two things in that:
- The direction is wrong (need exact opposite direction on color change).
- It should not stop. After the last color it should take the first color and then continue.