可自定义输入页码的jQuery分页插件jqPagination
jqPagination是一款基于jQuery的分页插件,这款jQuery分页插件非常实用,不仅可以上下翻页,而且也支持第一页和最后一页的翻页。 另外,jqPagination还支持自定义输入页码来跳转到任意页。jqPagination分页插件的UI外观也比较漂亮,分页按钮不仅大气,而且还 有渐变的颜色,看起来很简单,你可以将jqPagination应用在自己的个人博客上。
下面我们来简单介绍一下jqPagination分页插件实现的代码,主要由HTML代码、CSS代码以及jQuery代码组成,实现也比较简单。
HTML代码:
下面我们来简单介绍一下jqPagination分页插件实现的代码,主要由HTML代码、CSS代码以及jQuery代码组成,实现也比较简单。
HTML代码:
- <div>
- <a href="#" data-action="first">«a>
- <a href="#" data-action="previous">‹a>
- <input type="text" readonly="readonly" />
- <a href="#" data-action="next">›a>
- <a href="#" data-action="last">»a>
- div>
很简单,在页面上陈列了4个翻页按钮和一个页码输入框。
CSS代码:
- .pagination {
- display: inline-block;
- border: 1px solid #CDCDCD;
- border-radius: 3px; }
- .pagination a {
- display: block;
- float: left;
- width: 20px;
- height: 20px;
- outline: none;
- border-right: 1px solid #CDCDCD;
- border-left: 1px solid #CDCDCD;
- color: #555555;
- vertical-align: middle;
- text-align: center;
- text-decoration: none;
- font-weight: bold;
- font-size: 16px;
- font-family: Times, 'Times New Roman', Georgia, Palatino;
- /* ATTN: need a better font stack */
- background-color: #f3f3f3;
- background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #f3f3f3), color-stop(100%, lightgrey));
- background-image: -webkit-linear-gradient(#f3f3f3, lightgrey);
- background-image: linear-gradient(#f3f3f3, lightgrey); }
- .pagination a:hover, .pagination a:focus, .pagination a:active {
- background-color: #cecece;
- background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #e4e4e4), color-stop(100%, #cecece));
- background-image: -webkit-linear-gradient(#e4e4e4, #cecece);
- background-image: linear-gradient(#e4e4e4, #cecece); }
- .pagination a.disabled, .pagination a.disabled:hover, .pagination a.disabled:focus, .pagination a.disabled:active {
- background-color: #f3f3f3;
- background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #f3f3f3), color-stop(100%, lightgrey));
- background-image: -webkit-linear-gradient(#f3f3f3, lightgrey);
- background-image: linear-gradient(#f3f3f3, lightgrey);
- color: #A8A8A8;
- cursor: default; }
- .pagination a:first-child {
- border: none;
- border-radius: 2px 0 0 2px; }
- .pagination a:last-child {
- border: none;
- border-radius: 0 2px 2px 0; }
- .pagination input {
- float: left;
- margin: 0;
- padding: 0;
- width: 120px;
- height: 20px;
- outline: none;
- border: none;
- vertical-align: middle;
- text-align: center; }
- /* gigantic class for demo purposes */
- .gigantic.pagination {
- margin: 30px 0; }
- .gigantic.pagination a {
- height: 60px;
- width: 60px;
- font-size: 50px;
- line-height: 50px; }
- .gigantic.pagination input {
- width: 300px;
- height: 60px;
- font-size: 30px; }
以上就是jqPagination分页插件的实现过程,应该还算简单,大家可以下载源代码研究。