css - 自定义表格上的 CSS 材质选项卡不起作用
问题描述
在我的 Angular 5 应用程序中,我使用的是 Material API。
我有一个带有 2 个这样的标签的表格:
<mat-tab-group>
<mat-tab>
<mat-table>
<!-- some stuff -->
</mat-table>
</mat-tab>
<mat-table>
<!-- some stuff -->
</mat-table>
</mat-tab>
</mat-tab-group>
我尝试自定义<mat-tab>
组件的 css 但它不起作用,我一一尝试了所有这些:
.mat-tab-label-active {
color: rgb(255, 255, 255) !important;
background-color: red !important;
}
.mat-tab-nav-bar {
color: rgb(255, 255, 255) !important;
background-color: red !important;
}
.mat-tab-group {
color: rgb(255, 255, 255) !important;
background-color: rgba(19, 23, 63, 0.993) !important;
}
只有.mat-tab-group
在工作。我只想自定义选项卡单元格而不是整个选项卡组。有任何想法吗?
解决方案
按照我的评论:使用ng-template
垫标签的属性来自定义它们。堆栈闪电战
<mat-tab-group>
<mat-tab label="First">
<ng-template mat-tab-label>
<span class="customized-label">
This is a customized label
</span>
</ng-template>
</mat-tab>
<mat-tab label="Second"> Content 2 </mat-tab>
<mat-tab label="Third"> Content 3 </mat-tab>
</mat-tab-group>
.customized-label {
color: red;
font-weight: 700;
}
推荐阅读
- javascript - 如何检查变量是否以特定格式定义?
- java - 我设置了 INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory" 但它仍然在寻找 websphere
- javascript - 如何 SpyOn 原生 JavaScript 函数?比如.find()?
- firebase - FCM 主题速率限制
- c# - 使用 Netwonsoft 库序列化 JSON 时如何按字母顺序对属性进行排序?
- algorithm - 数值优化问题 - 在产品和场景之间进行选择所需的算法
- flask - 我可以将机器人状态数据存储在所涉及的电报聊天本身吗?
- dart - 使用三点 (...) 表示法在 Dart2 中添加条件映射条目有什么好处?
- node.js - 我的代码无法通过护照 js 重定向。身份验证问题
- angular - 如何在 Angular 中获取 HttpClient.Post 请求的响应标头