5

如何更改ngx-paginationCSS?我试过:

: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;
}

在组件.css中,但没有任何改变,我收到了这个警告

[弃用] CSS 动态配置文件不再支持 /deep/ 组合器。它现在实际上是无操作的,就像它是后代组合器一样。/deep/ 组合器将被移除,并且在 M65 时无效。你应该删除它。有关详细信息,请参阅https://www.chromestatus.com/features/4964279606312960 。

我该如何解决这个问题?感谢您的时间!

编辑:

.html

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

.css

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

编辑2:(渲染后的html)

<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>
4

5 回答 5

6

通过将所有样式设置为 !important 进行以下更改

组件.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;

}

于 2019-03-29T14:02:49.917 回答
4

而不是写这个

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

试着写这个

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

::ng-deep应该优先考虑更广泛的兼容性

于 2020-11-01T17:50:53.507 回答
0

搜索了一段时间后,我将此代码改编为我的 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;
  }
}

于 2022-01-08T22:54:14.417 回答
0

将您的 css 代码放在 styles.css 和不带 中/deep/​​,这是一个已弃用的伪类,用于禁用视图封装。

styles.css 文件是放置全局样式的地方。

于 2020-04-22T21:34:03.743 回答
0

将此代码放入 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;
}
于 2019-11-22T18:10:40.610 回答