GridView::widget([
'dataProvider' => $dataProvider
'layout' => "{summary}\n{items}\n<div class=''>{pager}</div>",
'columns' => $columns,
]);
默认情况下,GridView小部件将分页呈现为ul
标签,我希望改为使用table
。
align="center"
可以实现你的需求。请查看以下代码:
GridView::widget([
'dataProvider' => $dataProvider
'layout' => "{summary}\n{items}\n<div align='center'>{pager}</div>",
'columns' => $columns,
]);
GridView::widget([
'dataProvider' => $dataProvider
'layout' => "{summary}\n{items}\n<div class='text-center'>{pager}</div>",
'columns' => $columns,
]);
对于 bootstrap 4 小部件,请使用 justify-content-center
,例如:
GridView::widget([
'dataProvider' => $dataProvider
'layout' => "{summary}\n{items}\n<div class='d-flex justify-content-center'>{pager}</div>",
'columns' => $columns,
]);
或者
<div class="d-flex justify-content-center">
<?= LinkPager::widget([
'pagination' => $pagination,
]) ?>
</div>
针对Bootstrap4
GridView::widget([
'dataProvider' => $dataProvider
'layout' => "{summary}\n{items}\n<div class='mx-auto'>{pager}</div>",
'columns' => $columns,
]);
yii/helpers/BaseHml
。 - Thiago Augustus Oliveira