Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
677 views
in Technique[技术] by (71.8m points)

color of pagination bootstrap current page angular

I want to change color of pagination When in the current page and when you in the first page or last page pagination will disable

disable like this:

enter image description here

app.html

<ul *ngIf="(ticket$| async)?.length != 0" class="pagination justify-content-end">
  <li class="page-item">
    <a class="page-link" (click)="previousIndex()">Previous<span aria-hidden="true">&laquo;</span></a>
  </li>
  <li *ngFor="let i of getArrayFromNumber((ticket$| async)?.length); let in = index" class="page-item">
    <a class="page-link" (click)="updateIndex(in)">{{in+1}}<span class="sr-only">(current)</span></a>
  </li>
  <li class="page-item">
    <a class="page-link" (click)="nextIndex()">Next</a>
  </li>
</ul>

app.ts

  getArrayFromNumber(length) {
    this.max = (Math.ceil(length / 7))
    return new Array(Math.ceil(this.max));
  }

  updateIndex(pageIndex) {
    this.startIndex = pageIndex * 7;
    this.endIndex = this.startIndex + 7;
  }

  previousIndex() {
    if (this.tabindex > 0) {
      this.tabindex -= 1
    }
    this.startIndex = this.tabindex * 7;
    this.endIndex = this.startIndex + 7;
  }

  nextIndex() {
    if (this.tabindex < this.max - 1) {
      this.tabindex += 1
    }
    this.startIndex = this.tabindex * 7;
    this.endIndex = this.startIndex + 7;

  }
question from:https://stackoverflow.com/questions/66059343/color-of-pagination-bootstrap-current-page-angular

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Add the below CSS in your css file. Here for example I have used orange background color for current active page , you can change to any color as per your requirements.

.pagination > .active > a , .pagination > .active > a:hover, .pagination > .active > a:focus {
    background-color: orange;
    border-color: orange;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...