Angular material 如何设置特定角度材质组件的样式?
我使用的是角材质2,但我认为这也适用于角材质1 假设我想使用“angular material”选项卡,但我想隐藏这些选项卡或向其添加一些特定的样式 因此,我有以下html/angular材质代码:Angular material 如何设置特定角度材质组件的样式?,angular-material,angular-material2,Angular Material,Angular Material2,我使用的是角材质2,但我认为这也适用于角材质1 假设我想使用“angular material”选项卡,但我想隐藏这些选项卡或向其添加一些特定的样式 因此,我有以下html/angular材质代码: <md-tab-group> <md-tab> <template md-tab-label> <--- I want to style or hide all these. e.g. "height: 0"
<md-tab-group>
<md-tab>
<template md-tab-label> <--- I want to style or hide all these. e.g. "height: 0"
Some tab
</template>
<template md-tab-content>
Some content. Perhaps other tab components.
</template>
</md-tab>
<md-tab>
<template md-tab-label> <--- I want to style or hide all these. e.g. "height: 0"
Some tab
</template>
<template md-tab-content>
Some content. Perhaps other tab components.
</template>
</md-tab>
</md-tab-group>
可以从SCS/css覆盖材质样式。像这样:
/deep/.mat-tab-group.mat-primary.mat墨水条{
背景色:红色;
}
由于视图封装,您需要使用/deep/选择器,该选择器将允许您在渲染组件时获得添加的材质类。我建议避免使用/deep/,>>和::ng deep,因为它将被折旧。(而且看起来不太干净)
作为解决方案,我将在组件级别停用视图封装
@Component({
selector: 'app-card-list',
templateUrl: './card-list.component.html',
styleUrls: ['./card-list.component.scss'],
encapsulation: ViewEncapsulation.None
})
之后,我将为角材质组件创建一个带有SCS的周围div
.surrounding-div {
.mat-dialog {
display: flex;
flex-direction: row;
...
}
}
这是我最喜欢的设置角度材质组件样式的方法。玩得开心