Laravel框架自定義分頁(yè)樣式操作示例
本文實(shí)例講述了Laravel框架自定義分頁(yè)樣式操作。分享給大家供大家參考,具體如下:
操作步驟如下:
(1) 對(duì)應(yīng)public/css/paging.css 文件建立分頁(yè)樣式.
(2) 控制器查出分頁(yè)數(shù)據(jù)使用 paginate函數(shù)進(jìn)行分頁(yè)處理.(禁止使用group by處理查詢(xún)).
(3) 對(duì)應(yīng)視圖引入分頁(yè)樣式.
例如: paging.css 樣式文件代碼(復(fù)制即可用,實(shí)際操作過(guò))如下
#pull_right{
text-align:center;
}
.pull-right {
/*float: left!important;*/
}
.pagination {
display: inline-block;
padding-left: 0;
margin: 20px 0;
border-radius: 4px;
}
.pagination > li {
display: inline;
}
.pagination > li > a,
.pagination > li > span {
position: relative;
float: left;
padding: 6px 12px;
margin-left: -1px;
line-height: 1.42857143;
color: #428bca;
text-decoration: none;
background-color: #fff;
border: 1px solid #ddd;
}
.pagination > li:first-child > a,
.pagination > li:first-child > span {
margin-left: 0;
border-top-left-radius: 4px;
border-bottom-left-radius: 4px;
}
.pagination > li:last-child > a,
.pagination > li:last-child > span {
border-top-right-radius: 4px;
border-bottom-right-radius: 4px;
}
.pagination > li > a:hover,
.pagination > li > span:hover,
.pagination > li > a:focus,
.pagination > li > span:focus {
color: #2a6496;
background-color: #eee;
border-color: #ddd;
}
.pagination > .active > a,
.pagination > .active > span,
.pagination > .active > a:hover,
.pagination > .active > span:hover,
.pagination > .active > a:focus,
.pagination > .active > span:focus {
z-index: 2;
color: #fff;
cursor: default;
background-color: #428bca;
border-color: #428bca;
}
.pagination > .disabled > span,
.pagination > .disabled > span:hover,
.pagination > .disabled > span:focus,
.pagination > .disabled > a,
.pagination > .disabled > a:hover,
.pagination > .disabled > a:focus {
color: #777;
cursor: not-allowed;
background-color: #fff;
border-color: #ddd;
}
.clear{
clear: both;
}
例如:TestCntroller.php 控制器示例寫(xiě)法
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use App\Http\Controllers\Controller;
class TestController extends Controller{
/**
* 測(cè)試數(shù)據(jù)
*/
public function index()
{
$test = DB::table('test')->paginate(5);
return view('index', ['test' => $test]);
}
}
例如: list.blade.php 視圖文件代碼示例寫(xiě)法
<!--用于引用css-->
<link rel="stylesheet" type="text/css" href="{{asset('css/paging.css')}}" rel="external nofollow" />
<div class="container">
<!--查數(shù)據(jù)-->
@foreach ($test as $value)
{{ $value->id }}
@endforeach
</div>
<div id="pull_right">
<!--分頁(yè)寫(xiě)法-->
<div class="pull-right">
{{ $test->render() }}
</div>
</div>
樣式如下圖:

更多關(guān)于Laravel相關(guān)內(nèi)容感興趣的讀者可查看本站專(zhuān)題:《Laravel框架入門(mén)與進(jìn)階教程》、《php優(yōu)秀開(kāi)發(fā)框架總結(jié)》、《php面向?qū)ο蟪绦蛟O(shè)計(jì)入門(mén)教程》、《php+mysql數(shù)據(jù)庫(kù)操作入門(mén)教程》及《php常見(jiàn)數(shù)據(jù)庫(kù)操作技巧匯總》
希望本文所述對(duì)大家基于Laravel框架的PHP程序設(shè)計(jì)有所幫助。
- Laravel5.5 手動(dòng)分頁(yè)和自定義分頁(yè)樣式的簡(jiǎn)單實(shí)現(xiàn)
- PHP框架Laravel插件Pagination實(shí)現(xiàn)自定義分頁(yè)
- laravel自定義分頁(yè)效果
- laravel自定義分頁(yè)的實(shí)現(xiàn)案例offset()和limit()
- laravel實(shí)現(xiàn)分頁(yè)樣式替換示例代碼(增加首、尾頁(yè))
- Laravel手動(dòng)分頁(yè)實(shí)現(xiàn)方法詳解
- Laravel+jQuery實(shí)現(xiàn)AJAX分頁(yè)效果
- Laravel框架執(zhí)行原生SQL語(yǔ)句及使用paginate分頁(yè)的方法
- laravel手動(dòng)創(chuàng)建數(shù)組分頁(yè)的實(shí)現(xiàn)代碼
相關(guān)文章
搭建PhpStorm+PhpStudy開(kāi)發(fā)環(huán)境的超詳細(xì)教程
這篇文章主要介紹了搭建PhpStorm+PhpStudy開(kāi)發(fā)環(huán)境的超詳細(xì)教程,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-09-09
使用PHP抓取微博數(shù)據(jù)實(shí)現(xiàn)demo及原理解析
這篇文章主要為大家介紹了使用PHP抓取微博數(shù)據(jù)實(shí)現(xiàn)demo及原理解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-05-05
Laravel Memcached緩存驅(qū)動(dòng)的配置與應(yīng)用方法分析
這篇文章主要介紹了Laravel Memcached緩存驅(qū)動(dòng)的配置與應(yīng)用方法,結(jié)合實(shí)例形式分析了在Laravel框架配置Memcached緩存及相關(guān)使用方法,需要的朋友可以參考下2016-10-10
PHP實(shí)現(xiàn)的漢字拼音轉(zhuǎn)換和公歷農(nóng)歷轉(zhuǎn)換類(lèi)及使用示例
這篇文章主要介紹了PHP實(shí)現(xiàn)的漢字拼音轉(zhuǎn)換和公歷農(nóng)歷轉(zhuǎn)換類(lèi)及使用示例,精心整理自網(wǎng)上的資源,需要的朋友可以參考下2014-07-07
Laravel基礎(chǔ)-關(guān)于引入公共文件的兩種方式
今天小編就為大家分享一篇Laravel基礎(chǔ)-關(guān)于引入公共文件的兩種方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-10-10
ThinkPHP5.1驗(yàn)證碼功能實(shí)現(xiàn)的示例代碼
這篇文章主要介紹了ThinkPHP5.1驗(yàn)證碼功能實(shí)現(xiàn)的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-06-06
yii框架無(wú)限極分類(lèi)的實(shí)現(xiàn)方法
這篇文章主要為大家詳細(xì)介紹了yii框架無(wú)限極分類(lèi)的實(shí)現(xiàn)方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-04-04
PHP中ID設(shè)置自增后不連續(xù)的原因分析及解決辦法
這篇文章主要介紹了PHP中ID設(shè)置自增后不連續(xù)的原因分析及解決辦法的相關(guān)資料,需要的朋友可以參考下2016-08-08

