angular - PrimeNG - 如何在 p-table 中为单个组件更改 pTemplate="caption" 的样式
问题描述
我想p-table
只在一个组件中更改我的标题单元格的背景颜色,我该怎么做?
我试过了<ng-template pTemplate="caption" class="myStyle">
并 .myStyle{ background: rgb(9,169,121) !important; }
在 my.component.scss
但它不起作用。
帮我!谢谢!
编辑:终于成功了!我看到@Antikhippe 的答案,但我不得不添加
:host ::ng-deep { #myTable { .p
-datatable-thead{ 背景:红色;
} .p-datatable .p-datatable-thead > tr > th { 背景:继承;} } }
解决方案
pTemplate="caption"
只适合你的表头的一部分,你必须p-datatable-header
上课:
尝试这个:
:host ::ng-deep {
#myTable {
.p-datatable-header {
background-color: red;
}
}
}
我包围p-datatable-header
了类,#myTable
仅将这个 CSS 应用于具有myTable
id 的表:
<p-table id="myTable" [value]="products">
推荐阅读
- excel - .Net Core Regex Replace 返回的结果与 localhost 不同
- python - 满足条件时重新格式化数据框/添加行
- firebase - 量角器不喜欢angularfire
- r - 在 R 中,如何指定一组变量以在不同模型中重用?
- docker - 升级 Quarkus 1.11->1.13 的 Dockerfile
- javascript - 需要根据按钮单击的持续时间增加值
- c - 如何在脚本外壳中调用可执行 C?
- azure-data-factory - 数据流中的活动是否计入管道活动限制 40?
- android - Google Play - alpha 版 App Bundle,生产 - apk
- python - OpenCV 计算帧但不读取它们