Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
Perform Animation on border-bottom-width CSS property
The CSS border-bottom-width property can be animated to create dynamic visual effects. By using CSS animations, you can smoothly transition the bottom border width from one value to another over a specified duration.
Syntax
selector {
border-bottom-width: value;
animation: animation-name duration timing-function iteration-count;
}
@keyframes animation-name {
from { border-bottom-width: initial-value; }
to { border-bottom-width: final-value; }
}
Example
The following example demonstrates how to animate the border-bottom-width property from 5px to 50px −
<!DOCTYPE html>
<html>
<head>
<style>
.animated-box {
width: 300px;
height: 200px;
background-color: #4CAF50;
border-bottom: 5px solid #2E7D32;
margin: 50px auto;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-weight: bold;
animation: borderAnimation 2s ease-in-out infinite alternate;
}
@keyframes borderAnimation {
from {
border-bottom-width: 5px;
}
to {
border-bottom-width: 50px;
}
}
</style>
</head>
<body>
<h2>Animating Border Bottom Width</h2>
<div class="animated-box">Watch the bottom border!</div>
</body>
</html>
A green box appears with white text "Watch the bottom border!" The bottom border smoothly animates from 5px to 50px thickness and back, creating a pulsing effect that repeats continuously.
Complex Animation Example
Here's a more complex example that combines border width animation with color and radius changes −
<!DOCTYPE html>
<html>
<head>
<style>
.complex-box {
width: 400px;
height: 250px;
background: linear-gradient(45deg, #FF6B6B, #4ECDC4);
border-bottom: 10px solid #FF6B6B;
border-bottom-right-radius: 20px;
margin: 50px auto;
display: flex;
align-items: center;
justify-content: center;
color: white;
font-size: 18px;
font-weight: bold;
animation: complexBorderAnim 3s ease-in-out infinite;
}
@keyframes complexBorderAnim {
0% {
border-bottom-width: 10px;
border-bottom-color: #FF6B6B;
border-bottom-right-radius: 20px;
}
50% {
border-bottom-width: 40px;
border-bottom-color: #4ECDC4;
border-bottom-right-radius: 80px;
}
100% {
border-bottom-width: 10px;
border-bottom-color: #FF6B6B;
border-bottom-right-radius: 20px;
}
}
</style>
</head>
<body>
<h2>Complex Border Animation</h2>
<div class="complex-box">Multi-property Animation</div>
</body>
</html>
A colorful gradient box displays with text "Multi-property Animation". The bottom border animates from 10px to 40px width while simultaneously changing color from red to teal and increasing the border radius, creating a smooth, complex animation effect.
Conclusion
Animating the border-bottom-width property creates engaging visual effects for user interfaces. Combine it with other border properties like color and radius for more dynamic animations that enhance user experience.
Advertisements
