I want to change the color of a div border, so that the color changes every second to another color.
I don't know how to do this, any help? This is my code.
/* Style the links inside the list items */
ul.topnav li a {
display: inline-block;
border-left: 3px solid;
border-left-color: #FF0000;
border-top-color: #F5FF00;
border-top-style: double;
border-bottom: 3px solid;
border-bottom-color: #FF0000;
border-right-style: double;
border-right-color: #F5FF00;
border-radius: 40px;
color: #f2f2f2;
text-align: center;
padding: 14px 16px;
text-decoration: none;
transition: 0.3s;
font-size: 17px;
}
<header>
<ul class="topnav" id="drop">
<li><a class="selected" href="home.html">Home</a></li>
<li>
<a href="project.html">Project</a>
<ul>
<li><a href="project.html">Algemeen</a></li>
<li><a href="test.html">test</a></li>
<li><a href="test2.html">test2</a></li>
</ul>
</li>
<li><a href="contact.html">Contact</a></li>
<li class="icon">
<a href="javascript:void(0);" onclick="myFunction()">☰</a>
</li>
</ul>
</header>
If you know the sequence of the colors or simply you don't care, you can use a CSS rule called @Keyframes animation, it is compatible with most of the modern browsers and you can do a lot of tricky things like this:
.border-glow {
border: 1px solid blue;
animation: 4s infinite glow;
}
@keyframes glow {
0% {
border-color: red;
}
25% {
border-color: blue;
}
75% {
border-color: yellow;
}
100% {
border-color: purple;
}
}
@-webkit-keyframes glow {
0% {
border-color: red;
}
25% {
border-color: blue;
}
75% {
border-color: yellow;
}
100% {
border-color: purple;
}
}
<div class="border-glow">Shiny!</div>
Working jdfiddle demo.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With