Home > database >  Center ngx-pagination
Center ngx-pagination

Time:12-09

I have an ngx-pagination :

<pagination-controls
                  id="pagination"
                  (pageChange)="page = $event"
                  (pageBoundsCorrection)="page = $event"
                  [maxSize]="9"
                  [directionLinks]="true"
                  [autoHide]="true"
                  [responsive]="true"
                  previousLabel="Previous"
                  nextLabel="Next"
                  screenReaderPaginationLabel="Pagination"
                  screenReaderPageLabel="page"
                  screenReaderCurrentLabel="You're on page">
</pagination-controls>

Things with center like :

<div >
  <my-pagination></my-pagination>
</div>

are not working, cause the width of the pagination is alwayws 100% width of the page.

How can i make width of the pagination as small as possible and keep it responsible?

CodePudding user response:

CSS:

.mat-paginator-container {
  width: fit-content !important;
}

And if you want to center it everywhere add this too:

.mat-paginator-outer-container {
  justify-content: center !important;
}
  • Related