EN
CSS - pulsating color animated border (with border-radius)
3 points
In this article, we would like to show you how to create pulsating color animated border using CSS.
In order to create pulsating effect, we need to:
- set the element's border initial color,
- use
@keyframes
to create animation that changes border color, - assign the animation to the element, set its execution time and duration.
xxxxxxxxxx
1
2
<html>
3
<head>
4
<style>
5
6
.element {
7
padding: 5px;
8
border: 10px solid lightgreen; /* sets initial border color */
9
animation: pulse 2s infinite; /* sets effect, execution time and duration */
10
}
11
12
@keyframes pulse {
13
0% {
14
border-color: lightgreen; /* initial border color */
15
}
16
50% {
17
border-color: green; /* second border color */
18
}
19
100% {
20
border-color: lightgreen; /* initial border color */
21
}
22
}
23
24
</style>
25
</head>
26
<body>
27
<div class="element">Some text here ...</div>
28
</body>
29
</html>