[英]How to Change the styles of mat card which is used in Angular library component
I have used mat-card in angular library component like the below我在角库组件中使用了 mat-card,如下所示
<mat-card class="la-card">
<mat-card-header class="la-card__header">
<mat-card-subtitle>Field</mat-card-subtitle>
<mat-card-title>Case title</mat-card-title>
</mat-card-header>
<mat-card-content class="la-card__content">
<p>
The Shiba Inu is the smallest of the six original and distinct spitz breeds of dog from Japan.
A small.
</p>
</mat-card-content>
<mat-card-actions class='la-card__actions'>
<button mat-button>Created</button>
<button mat-button>Details</button>
</mat-card-actions>
and i gave the style like the below我给出了如下样式
.la-card__header { margin: 0; flex-shrink: 0; .mat-card-header-text { margin: 0; } }
The margin '0' is not applying to header text class .mat-card-header-text.边距“0”不适用于标题文本类 .mat-card-header-text。 How can i remove the margin to that classs.
如何删除该类的边距。 That class i can see when i inspect the mat-card component.
当我检查 mat-card 组件时,我可以看到那个类。
Use the following css selector to reach deep angular classes ::ng-deep
.使用以下 css 选择器来达到深角度类
::ng-deep
。
CSS rule that resets margin in this case would be:在这种情况下重置边距的 CSS 规则是:
::ng-deep .mat-card-header-text {
margin: 0;
}
And as for a full code snippet it would be:至于完整的代码片段,它将是:
.la-card__header {
margin: 0;
flex-shrink: 0;
::ng-deep .mat-card-header-text {
margin: 0;
}
}
Hope This helped.希望这有帮助。
You can use the deep class selector when selecting your class .mat-card-header-text
.您可以在选择类
.mat-card-header-text
时使用深层类选择器。
.<your-class> {
.<parent-class> {
.la-card__header {
.mat-card-header-text {
margin: 0;
}
}
}
}
In this example, we are adding an extra class selector to beat the material CSS selector.在这个例子中,我们添加了一个额外的类选择器来击败材质 CSS 选择器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.