Perform Animation on CSS border-bottom-color property

The CSS border-bottom-color property can be animated to create smooth color transitions for the bottom border of an element. This property is animatable, allowing you to create engaging visual effects.

Syntax

selector {
    border-bottom-color: color;
    animation: animation-name duration timing-function;
}

@keyframes animation-name {
    from { border-bottom-color: initial-color; }
    to { border-bottom-color: final-color; }
}

Example: Animating Border Bottom Color

The following example demonstrates how to animate the border-bottom-color property from blue to red over a 2-second duration −

<!DOCTYPE html>
<html>
<head>
<style>
    .animated-box {
        width: 300px;
        height: 150px;
        background-color: #f0f0f0;
        border: 5px solid transparent;
        border-bottom: 5px solid blue;
        animation: colorChange 2s infinite alternate;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        font-weight: bold;
        margin: 20px;
    }
    
    @keyframes colorChange {
        0% {
            border-bottom-color: blue;
        }
        100% {
            border-bottom-color: red;
        }
    }
</style>
</head>
<body>
    <h2>Border Bottom Color Animation</h2>
    <div class="animated-box">Watch the bottom border!</div>
</body>
</html>
A gray box with centered text appears with a bottom border that smoothly transitions from blue to red and back repeatedly every 2 seconds.

Example: Multi-Color Transition

You can create more complex animations with multiple color stops using percentage keyframes −

<!DOCTYPE html>
<html>
<head>
<style>
    .rainbow-border {
        width: 400px;
        height: 100px;
        background-color: white;
        border: 3px solid transparent;
        border-bottom: 8px solid red;
        animation: rainbow 3s infinite linear;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 16px;
        margin: 20px;
    }
    
    @keyframes rainbow {
        0% { border-bottom-color: red; }
        16.66% { border-bottom-color: orange; }
        33.33% { border-bottom-color: yellow; }
        50% { border-bottom-color: green; }
        66.66% { border-bottom-color: blue; }
        83.33% { border-bottom-color: indigo; }
        100% { border-bottom-color: violet; }
    }
</style>
</head>
<body>
    <h2>Rainbow Bottom Border Animation</h2>
    <div class="rainbow-border">Colorful Border Animation</div>
</body>
</html>
A white box with text displays a continuously cycling rainbow-colored bottom border that smoothly transitions through red, orange, yellow, green, blue, indigo, and violet.

Conclusion

The border-bottom-color property can be effectively animated using CSS keyframes to create smooth color transitions. Use percentage keyframes for multi-color effects and timing functions to control the animation pace.

Updated on: 2026-03-15T13:19:54+05:30

153 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements