本文实例讲述了laravel框架自定义分页样式操作。分享给大家供大家参考,具体如下:
操作步骤如下:
(1) 对应public/css/paging.css 文件建立分页样式.
(2) 控制器查出分页数据使用 paginate函数进行分页处理.(禁止使用group by处理查询).
(3) 对应视图引入分页样式.
例如: paging.css 样式文件代码(复制即可用,实际操作过)如下
#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 2021中秋国庆放假安排公布时间{ 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, .paginatio怀念母亲的诗n > .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 控制器示例写法
<?phpnamespace app\http\controllers;u illuminate\support\facades\db;u app\http\controllers\controller;class testcontroller extends controller{ /** * 测试数据 */ p中秋假期ublic function igc数学index() { $test = db::table('test')->paginate(5); return view('index', ['test' => $test]); }}
例如: list.blade.php 视图文件代码示例写法
<!--用于引用css--><link rel="stylesheet" type="text/css" href="{{ast('css/paging.css')}}" rel="external nofollow" /><div class="container"> <!--查数据--> @foreach ($test as $value) {{ $value->id }} @endforeach</div><div id="pull_right"> <!--分页写法--> <div class="pull-right"> {{ $test->render() }} </div></div>
样式如下图:
本文发布于:2023-04-08 14:52:37,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/zuowen/688023373605989b40aa06e9d541394e.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文word下载地址:Laravel框架自定义分页样式操作示例.doc
本文 PDF 下载地址:Laravel框架自定义分页样式操作示例.pdf
留言与评论(共有 0 条评论) |