如何自定义ngx-datatable行的CSS

huangapple go评论99阅读模式
英文:

How to customize ngx-datatable css for rows

问题

我尝试为ngx-datatable元素应用一些CSS,如下所示。

  1. .datatable-body-row:hover {
  2. background-color: #3387b5;
  3. }

没有任何变化,结果仍然相同。CSS保持默认设置。
当我将鼠标悬停在特定行上时,颜色仍然相同。
我如何自定义它?谢谢。

供参考,整体的HTML结构如下。

  1. <ngx-datatable>
  2. <!-- 行包含在这些列中,但这些列包含标题 -->
  3. <ngx-datatable-column>
  4. <ng-template ngx-datatable-header-template>
  5. <label class="datatable-checkbox">
  6. <input />
  7. </label>
  8. </ng-template>
  9. <ng-template ngx-datatable-cell-template >
  10. <label class="datatable-checkbox">
  11. <input type="checkbox" />
  12. </label>
  13. </ng-template>
  14. </ngx-datatable-column>
  15. <ngx-datatable-column *ngFor="let column of columns; let i = index">
  16. </ngx-datatable-column>
  17. </ngx-datatable>
英文:

I try to apply some css for the ngx-datatable element like this.

  1. .datatable-body-row:hover {
  2. background-color: #3387b5;
  3. }

Nothing changed, result are the same. The css remains default setting.
The color is still the same when I hover my mouse to the specific row.
How can I customize it? Thankyou.

For reference the over all HTML structure are like this.

  1. &lt;ngx-datatable &gt;
  2. &lt;!-- row are included in these column, but these column includes header--&gt;
  3. &lt;ngx-datatable-column &gt;
  4. &lt;ng-template ngx-datatable-header-template&gt;
  5. &lt;label class=&quot;datatable-checkbox&quot;&gt;
  6. &lt;input /&gt;
  7. &lt;/label&gt;
  8. &lt;/ng-template&gt;
  9. &lt;ng-template ngx-datatable-cell-template &gt;
  10. &lt;label class=&quot;datatable-checkbox&quot;&gt;
  11. &lt;input type=&quot;checkbox&quot; /&gt;
  12. &lt;/label&gt;
  13. &lt;/ng-template&gt;
  14. &lt;/ngx-datatable-column&gt;
  15. &lt;ngx-datatable-column *ngFor=&quot;let column of columns; let i = index&quot; &gt;
  16. &lt;/ngx-datatable-column&gt;
  17. &lt;/ngx-datatable&gt;

答案1

得分: 1

可能降低CSS优先级

您可以使用这种方法或其他方式提高优先级:https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity

  1. .datatable-body-row:hover,
  2. .datatable-body-row:hover .datatable-row-group {
  3. background-color: #3387b5 !important;
  4. }
英文:

Probably lower CSS Priority

you can use this or raise Priority other way https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity

  1. .datatable-body-row:hover,
  2. .datatable-body-row:hover .datatable-row-group {
  3. background-color: #3387b5 !important;
  4. }

huangapple
  • 本文由 发表于 2023年1月9日 17:44:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/75055452.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定