Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to change ngb-pagination background color

I try to set background color to ngb-pagination item for angular2, but is does not work.

<ngb-pagination style="background-color:gray;" [collectionSize]="120" [(page)]="page" [maxSize]="5" [boundaryLinks]="true">

Thank you.

like image 731
Samet ÇELİKBIÇAK Avatar asked Oct 15 '18 19:10

Samet ÇELİKBIÇAK


People also ask

How do I remove current from NGB pagination?

For, removing the (current), maybe you can add a CSS style of display: none or visibility: hidden for that element.

What is the pagination in angular?

Pagination is a component that only displays page numbers. It will not manipulate your data collection. You will have to split your data collection into pages yourself.


3 Answers

I don't if this library provide a way to customize the theme, if there that will be the best way.

But if you want to override some of the component inner styles you can use ::ng-deep.

    ngb-pagination ::ng-deep ul > li:not(.active) > a {
          background-color: red !important;
    }

    ngb-pagination ::ng-deep ul > li.active > a {
          background-color: lightgreen !important;
    }

Also style="background-color:gray;" will definitely not work, you can see the DOM and it's style

like image 83
Vivek Kumar Avatar answered Oct 24 '22 09:10

Vivek Kumar


A little late to the party, but I got it to work in Angular 8 by adding the following code to my css file:

ngb-pagination ::ng-deep a {
  color: black !important;
}

ngb-pagination ::ng-deep .page-item.active .page-link {
  border-color: black;
  background-color: lightgrey;
}

ngb-pagination ::ng-deep .page-item.active .page-link:focus, .page-link:not(:disabled):not(.disabled):active:focus {
  box-shadow: 0 0 0 0.1rem dimgrey;
}

ngb-pagination ::ng-deep .page-link:not(:disabled):not(.disabled):active:focus {
  box-shadow: 0 0 0 0.1rem dimgrey;
}
like image 37
HansDrita Avatar answered Oct 24 '22 09:10

HansDrita


I found the solution, thank for helping. In my condition problem solved like that in my css file. To overwrite the pagination stuff just using /deep/ keyword.

/deep/ .pagination .page-item .page-link {
  border-radius: 0 !important;
}

/deep/ .pagination .page-link {
  border-top-style: none !important;
  border-bottom-style: none !important;
  background-color: #f6f6f6 !important;
  color: black !important;
}

Thank you.

like image 42
Samet ÇELİKBIÇAK Avatar answered Oct 24 '22 07:10

Samet ÇELİKBIÇAK