正值新手的我们,在thinkphp的开发中我们遇到分页效果不知道怎么写的,那么现在作者就给大家举个例子
控制器端:
$list = $mod->where($where)->orderRaw('sort asc,id desc')->paginate($pageSize);
视图层:
<div class="pageshow">
{$page|raw}
</div>
css样式:
/*分页效果*/
.pageshow{padding:20px;background-color:#fff;text-align:center}
.pageshow .pagination{display:inline-block;*display:inline;*zoom:1;margin-left:0;margin-bottom:0}
.pageshow .pagination > li{margin: 0 2px; list-style:none; float:left; -webkit-transition: all .5s linear .2s; transition: all .2s linear .2s;}
.pageshow .pagination > li a{color: #000;display: block; padding: 2px 20px; line-height: 30px; text-align: center; margin: 0 auto;}
.pageshow .pagination > li,.pageshow .pagination > span{float:left;line-height:20px;text-decoration:none;background-color:#eee;color:#666}
.pageshow .pagination > li a:hover,.pageshow .pagination > a:focus{background-color:#ccc;color:#444}
.pageshow .pagination > li.active{background-color:#FFFFFF;}
.pageshow .pagination > li.active > a,.pageshow .pagination > .active > span{color:#000}
.pageshow .pagination > li.active > a,.pageshow .pagination > .active > span{cursor:default;font-size: 14px;}
.pageshow .pagination > li span,.pageshow .pagination > .disabled > span,.pageshow .pagination .disabled > a,.pageshow .pagination .disabled > a:hover,.pageshow .pagination .disabled > a:focus{line-height: 30px; padding: 2px 20px; color:#999999;background-color:transparent;cursor:default}
至此,一个好看的tp分页样式效果就做出来了