angular - ngx-bootstrap:如何改变分页按钮的外观
问题描述
我在我的项目中使用来自 ngx-bootstrap 的分页组件,并尝试更改按钮以及它的外观和失败方式。有没有办法改变它?
我的组件:
<div class="table-container">
<table class="table">
<thead>
<tr class="table-nav">
<th scope="col">שנה</th>
<th scope="col">סוג הדוח</th>
<th scope="col">ח.פ</th>
<th scope="col">שם החברה</th>
</tr>
</thead>
<tbody>
<ng-container *ngFor="let tax of currentPage">
<tr>
<td>{{tax.year}}</td>
<td>{{tax.type}}</td>
<td>{{tax.cid}}</td>
<td>{{tax.company}}</td>
</tr>
</ng-container>
</tbody>
</table>
<div class="table-footer">
<pagination class="pagination" nextText=">" previousText="<" [align]="true"
[totalItems]="totalItems" (pageChanged)="pageChanged($event)">
</pagination>
</div>
</div>
这是默认样式:
我需要让它看起来像这样:
解决方案
我首先通过在我的分页元素中添加一个类 my-pagination 来修复它,例如
<pagination
[maxSize]="maxSizeBtn"
[firstText]="firstText"
[lastText]="lastText"
[previousText]="prevText"
[nextText]="nextText"
[itemsPerPage]="perPage"
[boundaryLinks]="showBoundaryLinks"
[totalItems]="totalItems"
[(ngModel)]="currentPage"
(pageChanged)="pageChanged($event)"
(numPages)="smallnumPages = $event"
id="comp-pagination"
class="my-pagination"
></pagination>
在此之后,我强制所选页面项目必须具有像这样的红色背景颜色。你把 CSS 指令放在你的 .css 组件文件中
// 改变分页背景选择按钮颜色
.my-pagination::ng-deep .page-item.active .page-link {
z-index: 1;
color: #FFFFFF;
background-color:red !important;
border-color: #009DA0;
}
不要忘记覆盖所选页面项目的默认背景颜色的 !important 指令
谢谢
推荐阅读
- apn - APN 以及它们如何影响调制解调器的网络连接状态
- c# - 无论我尝试什么,CreatedAtAction 都会抛出 InvalidOperationExceptions
- python - Python Teradata 快速加载失败
- php - Codeigniter 限制和偏移分页不按降序工作
- azure-functions - 如何使用参数和文件调试 http 触发的 azure 函数
- angular - 从 api 获取 Okta 的客户端 ID 并在前端(Angular)中分配它
- github - 在 github 桌面上打开一个 git 会自动创建一个 fork 吗?
- javascript - 为什么通过 cypress-firebase npm 模块登录时 firebase 未定义?
- sql - Dbeaver 中的日期差异
- python - 在python py-game中碰撞时粒子重叠