分页(Pagination)是一种将大量数据分割成多个页面显示的技术,常用于网站和应用程序中,以提高用户体验和数据加载效率。CSS(层叠样式表)用于美化分页的样式,使其更加美观和易用。
以下是一个简单的CSS分页样式示例:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CSS Pagination</title>
<style>
.pagination {
display: flex;
justify-content: center;
margin-top: 20px;
}
.pagination a {
color: black;
float: left;
padding: 8px 16px;
text-decoration: none;
transition: background-color .3s;
border: 1px solid #ddd;
}
.pagination a.active {
background-color: #4CAF50;
color: white;
border: 1px solid #4CAF50;
}
.pagination a:hover:not(.active) {
background-color: #ddd;
}
</style>
</head>
<body>
<div class="pagination">
<a href="#">«</a>
<a href="#">1</a>
<a href="#" class="active">2</a>
<a href="#">3</a>
<a href="#">4</a>
<a href="#">5</a>
<a href="#">»</a>
</div>
</body>
</html>
通过以上内容,你应该对CSS分页有了更全面的了解,并能够解决一些常见问题。
领取专属 10元无门槛券
手把手带您无忧上云