Tenzolinho
Tenzolinho

Reputation: 982

Change ngx-pagination CSS

How can I change ngx-pagination CSS? I tried with:

:host /deep/ .ngx-pagination {
  padding-left: 0px;
}

:host /deep/.ngx-pagination .current,
.btn-info {
  background: #17a2b8 !important;
  border: transparent;
  border-radius: 20px;
}

:host /deep/.ngx-pagination .current:hover {
  background: #17a2b8 !important;
  border-radius: 20px;
  border: transparent;
}

inside component .css, but nothing changed, and I get this warning

[Deprecation] /deep/ combinator is no longer supported in CSS dynamic profile.It is now effectively no-op, acting as if it were a descendant combinator. /deep/ combinator will be removed, and will be invalid at M65. You should remove it. See https://www.chromestatus.com/features/4964279606312960 for more details.

How can I solve this? Thank you for your time!

EDIT:

.html

  <div class="clearfix">
    <pagination-controls (pageChange)="p = $event"></pagination-controls>
  </div>

.css

.clearfix {
  position: relative;
  right: 35%;
  left: 35%;
  font-size: 14px;
}

EDIT 2: (html after render)

<div class="clearfix">
    <pagination-controls nextlabel="Next" previouslabel="Previous" ng-reflect-previous-label="Previous"
      ng-reflect-next-label="Next">
      <pagination-template ng-reflect-max-size="7">
        <!--bindings={
    "ng-reflect-ng-if": "true"
  }-->
        <ul class="ngx-pagination ng-star-inserted" role="navigation" aria-label="Pagination">
          <!--bindings={
    "ng-reflect-ng-if": "true"
  }-->
          <li class="pagination-previous disabled ng-star-inserted">
            <!--bindings={
    "ng-reflect-ng-if": "false"
  }-->
            <!--bindings={
    "ng-reflect-ng-if": "true"
  }--><span class="ng-star-inserted"> Previous <span class="show-for-sr">page</span></span></li>
          <li class="small-screen"> 1 / 93 </li>
          <!--bindings={
    "ng-reflect-ng-for-of": "[object Object],[object Object"
  }-->
          <li class="current ng-star-inserted">
            <!--bindings={
    "ng-reflect-ng-if": "false"
  }-->
            <!--bindings={
    "ng-reflect-ng-if": "true"
  }-->
            <!----><span class="show-for-sr ng-star-inserted">You're on page </span><span class="ng-star-inserted">1</span></li>
          <li class="ng-star-inserted">
            <!--bindings={
    "ng-reflect-ng-if": "true"
  }--><a tabindex="0" class="ng-star-inserted"><span class="show-for-sr">page
              </span><span>2</span></a>
            <!--bindings={
    "ng-reflect-ng-if": "false"
  }-->
          </li>
          <li class="ng-star-inserted">
            <!--bindings={
    "ng-reflect-ng-if": "true"
  }--><a tabindex="0" class="ng-star-inserted"><span class="show-for-sr">page
              </span><span>3</span></a>
            <!--bindings={
    "ng-reflect-ng-if": "false"
  }-->
          </li>
          <li class="ng-star-inserted">
            <!--bindings={
    "ng-reflect-ng-if": "true"
  }--><a tabindex="0" class="ng-star-inserted"><span class="show-for-sr">page
              </span><span>4</span></a>
            <!--bindings={
    "ng-reflect-ng-if": "false"
  }-->
          </li>
          <li class="ng-star-inserted">
            <!--bindings={
    "ng-reflect-ng-if": "true"
  }--><a tabindex="0" class="ng-star-inserted"><span class="show-for-sr">page
              </span><span>5</span></a>
            <!--bindings={
    "ng-reflect-ng-if": "false"
  }-->
          </li>
          <li class="ellipsis ng-star-inserted">
            <!--bindings={
    "ng-reflect-ng-if": "true"
  }--><a tabindex="0" class="ng-star-inserted"><span class="show-for-sr">page
              </span><span>...</span></a>
            <!--bindings={
    "ng-reflect-ng-if": "false"
  }-->
          </li>
          <li class="ng-star-inserted">
            <!--bindings={
    "ng-reflect-ng-if": "true"
  }--><a tabindex="0" class="ng-star-inserted"><span class="show-for-sr">page
              </span><span>93</span></a>
            <!--bindings={
    "ng-reflect-ng-if": "false"
  }-->
          </li>
          <!--bindings={
    "ng-reflect-ng-if": "true"
  }-->
          <li class="pagination-next ng-star-inserted">
            <!--bindings={
    "ng-reflect-ng-if": "true"
  }--><a tabindex="0" aria-label="Next page" class="ng-star-inserted">
              Next <span class="show-for-sr">page</span></a>
            <!--bindings={
    "ng-reflect-ng-if": "false"
  }-->
          </li>
        </ul>
      </pagination-template>
    </pagination-controls>
  </div>

Upvotes: 6

Views: 24195

Answers (7)

Jean Carlo Lo Iacono
Jean Carlo Lo Iacono

Reputation: 47

it is really difficult but I managed to change the style of the ngx-pagination library and I explain below how I did it, I hope someone can help you.

HTML and CSS

/* red background at the number*/
.pagination-spreads::ng-deep li {
  background-color: red;
 }

/* I hide the previus when I am at number 1. with ::before */
.pagination-spreads::ng-deep ul > li.disabled {
  display: none !important;
}

/* deactivated numbers will be grayed out */
.pagination-spreads::ng-deep ul > li:not(.active) > a {
  background-color: rgb(142, 142, 142) !important;
  border-color: black !important;
  color: #fff;
}
<div class="d-flex justify-content-center">
    <pagination-controls previousLabel="Prev" nextLabel="Next" (pageChange)="currentPage = $event"
                        class="pagination-spreads">
    </pagination-controls>
</div>

the renter code hereesult is:

Upvotes: 0

manjit
manjit

Reputation: 1

::ng-deep .ngx-pagination a, .ngx-pagination button {
  position: relative;
  display: block;
  padding: 0.5rem 0.75rem;
  width: 38.6px;
  height: 36px;
  padding: 10px 0 9px;
  border: solid 1px #e4e4e4;
  
  // font-family: Roboto;
  // font-size: 14px;
  // font-weight: normal;
  // font-stretch: normal;
  // font-style: normal;
  line-height: 1.5;
  letter-spacing: normal;
  text-align: center;
  // color: #73818f;

  // & span {
    // width: 39.7px;
    // height: 17px;
    // font-family: Roboto;
    // font-size: 14px;
    // font-weight: normal;
    // font-stretch: normal;
    // font-style: normal;
    // line-height: 1.5;
    // letter-spacing: normal;
    // text-align: center;
    // color: var(--steel);
  // }
}

::ng-deep .ngx-pagination .current {
  padding: 0.5rem 0.75rem;
  margin-left: -1px;
  line-height: 1.25;
  width: 38.6px;
  height: 36px;
  padding: 0.5rem 0.75rem;
  border: solid 1px #38495e;
  background-color: rgba(56, 73, 94, 0.2);
}

::ng-deep .ngx-pagination .pagination-previous a:before, .ngx-pagination .pagination-previous.disabled:before {
  content: "<" !important;
}

::ng-deep .ngx-pagination .pagination-next a:after, .ngx-pagination .pagination-previous.disabled:after {
  content: ">" !important;
}
     
::ng-deep  li.pagination-previous.disabled:before {
  content: "<" !important;
}
::ng-deep  li.pagination-next.disabled:after {
  content: ">" !important;
}

Upvotes: 0

Joel Joseph
Joel Joseph

Reputation: 6169

make the following changes by setting all style to !important

component.css

.ngx-pagination {
  padding-left: 0px !important;
}

.ngx-pagination .current,
.btn-info {
  background: #17a2b8 !important;
  border: transparent !important;
  border-radius: 20px !important;
}

.ngx-pagination .current:hover {
  background: #17a2b8 !important;
  border-radius: 20px !important; 
  border: transparent !important;
}

Upvotes: 8

Daniel
Daniel

Reputation: 1

After searching for some time, I adapted this code to my CSS...

.ngx-pagination {
  margin-left: 0 !important;
  margin-bottom: 1rem !important;
  line-height: 20px !important;
  padding: 7px 15px 7px !important;
  font-size: 12px !important;
}
.ngx-pagination::before,
.ngx-pagination::after {
  content: " " !important;
  display: table !important;
}

.ngx-pagination::after {
  clear: both !important;
}

.ngx-pagination li {
  -moz-user-select: none !important;
  -webkit-user-select: none !important;
  -ms-user-select: none !important;
  margin-right: 0.2rem !important;
  border-radius: 0 !important;
}

.ngx-pagination li {
  display: inline-block !important;
}

.ngx-pagination a,
.ngx-pagination button {
  color: #0a0a0a !important;
  display: block !important;
  background-color: rgb(248, 248, 248) !important;
  color: black !important;
  border: 2px solid #8b8b8b !important;
  padding: 0.5rem 1rem !important;
  border-radius: 9% !important;
}

.ngx-pagination a:hover,
.ngx-pagination button:hover {
  background: #788b8d88 !important;
}

.ngx-pagination .current {
  padding: 0.1875rem 0.625rem !important;
  background: #2199e8 !important;
  color: #fefefe !important;
  cursor: default !important;
  border: 2px solid #8b8b8b !important;
  padding: 0.5rem 1rem !important;
  border-radius: 9% !important;
}

.ngx-pagination .disabled {
  padding: 0.1875rem 0.625rem !important;
  color: #cacaca00 !important;
  cursor: default !important;
}

.ngx-pagination .disabled:hover {
  background: transparent !important;
}

.ngx-pagination a,
.ngx-pagination button {
  cursor: pointer !important;
}

.ngx-pagination .pagination-previous a::before,
.ngx-pagination .pagination-previous.disabled::before {
  font-family: FontAwesome;
  content: "\f053" !important;
  display: inline-block !important;
  margin-right: 0rem !important;
}

.ngx-pagination .pagination-next a::after,
.ngx-pagination .pagination-next.disabled::after {
  font-family: FontAwesome !important;
  content: "\f054" !important;
  display: inline-block !important;
  margin-left: 0rem !important;
}

.ngx-pagination .show-for-sr {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
}

.ngx-pagination .small-screen {
  display: none !important;
}

@media screen and (max-width: 601px) {
  .ngx-pagination.responsive .small-screen {
    display: inline-block !important;
    color: black !important;
    background-color: rgb(248, 248, 248) !important;
    border: 2px solid #8b8b8b !important;
    padding: 0.5rem 1rem !important;
    border-radius: 9% !important;
  }
  .ngx-pagination.responsive
    li:not(.small-screen):not(.pagination-previous):not(.pagination-next) {
    display: none !important;
  }
}

Upvotes: 0

scriptman
scriptman

Reputation: 41

Instead of writing this

.paginator /deep/ .ngx-pagination .current {
    background: red;
}

try tο write this

.pagination ::ng-deep .ngx-pagination .current {
    background: red;
}

::ng-deep should be preferred for a broader compatibility

Upvotes: 4

Floxaz
Floxaz

Reputation: 1

Put your css code inside styles.css and without /deep/, which is a deprecated pseudo-class used to disable view-encapsulation.

The styles.css file is where you put global styles.

Upvotes: 0

Sebastian Jose
Sebastian Jose

Reputation: 309

Put this code in myComponent.css

.paginator{
    font-family: 'Lato', sans-serif;
    font-size: 15px;
}

.paginator /deep/ .ngx-pagination .current {
    background: rgb(131, 131, 131);
    border-radius: 4px;
    padding-left: 9px;
    padding-right: 9px;
}

.paginator /deep/ .ngx-pagination a:hover, .ngx-pagination button:hover {
    background: #d4d4d4;
    border-radius: 3px;
    padding-left: 9px;
    padding-right: 9px;
    text-decoration: none;
}

.paginator /deep/ .ngx-pagination a:focus, .ngx-pagination button:focus {
    outline: none;
    background: #d4d4d4;
}

Upvotes: 0

Related Questions