Languages
[Edit]
EN

CSS - pulsating color animated border (with border-radius)

3 points
Created by:
Evania
584

In this article, we would like to show you how to create pulsating color animated border using CSS.

Practical example

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.
// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<head>
  <style>

    .element {
        padding: 5px;
        border: 10px solid lightgreen;  /* sets initial border color                */
        animation: pulse 2s infinite;   /* sets effect, execution time and duration */
    }

    @keyframes pulse {
        0% {
            border-color: lightgreen;  /* initial border color */
        }
        50% {
            border-color: green;       /* second border color  */
        }
        100% {
            border-color: lightgreen;  /* initial border color */
        }
    }

  </style>
</head>
<body>
  <div class="element">Some text here ...</div>
</body>
</html>

 

See also

  1. CSS - gradient border with radius

  2. CSS - keyframes animations

References

  1. border - CSS: Cascading Style Sheets | MDN
  2. border-radius - CSS: Cascading Style Sheets | MDN
  3. @keyframes - CSS: Cascading Style Sheets | MDN
  4. Using CSS animations - CSS: Cascading Style Sheets | MDN

Alternative titles

  1. CSS - changing color animated border (with border-radius)
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join