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
Create a transition effect on hover pagination with CSS
To create a transition effect on hover pagination, use the CSS transition property. This property allows you to smoothly animate changes in CSS properties when a user hovers over pagination links, creating a professional and interactive user experience.
Syntax
selector {
transition: property duration timing-function delay;
}
Example
You can try to run the following code to add transition effect −
<!DOCTYPE html>
<html>
<head>
<style>
.demo {
display: inline-block;
margin: 20px;
}
.demo a {
color: #333;
padding: 8px 16px;
text-decoration: none;
border-radius: 5px;
margin: 0 2px;
background-color: #f1f1f1;
border: 1px solid #ddd;
transition: all 0.3s ease;
}
.demo a.active {
background-color: #4CAF50;
color: white;
border-color: #4CAF50;
}
.demo a:hover:not(.active) {
background-color: #ddd;
transform: translateY(-2px);
box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}
</style>
</head>
<body>
<h2>Page Navigation</h2>
<div class="demo">
<a href="#">«</a>
<a href="#">1</a>
<a href="#">2</a>
<a href="#" class="active">3</a>
<a href="#">4</a>
<a href="#">5</a>
<a href="#">»</a>
</div>
</body>
</html>
A pagination component with numbered links appears. When hovering over any non-active link, it smoothly transitions with a background color change, lifts slightly upward, and displays a subtle shadow effect. The active page (3) remains highlighted in green.
Key Properties
| Property | Description |
|---|---|
transition |
Shorthand for all transition properties |
transition-duration |
How long the transition takes |
transition-property |
Which CSS properties to animate |
transition-timing-function |
Speed curve of the transition |
Conclusion
CSS transitions on pagination create smooth, professional hover effects that enhance user experience. Combine transition with properties like background-color, transform, and box-shadow for engaging interactive pagination components.
Advertisements
