首页 新闻 会员 周边

angular: 如何在不增加 css class 的情况设置 mat-table 的样式

0
悬赏园豆:30 [已解决问题] 解决于 2023-07-20 09:49

angular 项目中的 component html 代码

<table mat-table>
    <ng-container>
      <td mat-cell></td>
    </ng-container>
    <ng-container>
      <td mat-cell></td>
    </ng-container>
</table>

运行时生成的 mat-table html 代码

<table _ngcontent-qty-c136 mat-table>
    <td _ngcontent-qty-c136 mat-cell></td>
    <td _ngcontent-qty-c136 mat-cell></td>
</table>

想分别针对 mat-tablemat-cell 设置 tabletd 的样式,

dudu的主页 dudu | 高人七级 | 园豆:30948
提问于:2023-07-20 09:03
< >
分享
最佳答案
0

通过 table[mat-table] td[mat-cell] css 选择器解决了

table[mat-table] {
  width: 100%;
  padding: 10px;
}

td[mat-cell] {
  width: 50%;
}
dudu | 高人七级 |园豆:30948 | 2023-07-20 09:49
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册