本文介绍了覆盖 Angular 组件中的 Angular Material 样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在我的 Angular 组件中使用 Material 2 .我想覆盖其中一个类,例如
.mat-input-wrapper
在 Angular Material 中定义.但我只想在该组件中覆盖,并且覆盖不应影响页面中的其他组件.
I am using Material 2 <md-input-container>
in my Angular component. I want to override one of the classes e.g. .mat-input-wrapper
defined in Angular Material. But I want to override only in that component and the override should not effect other components in the page.
这是渲染元素的屏幕截图:
Here is the screenshot of the rendered element:
推荐答案
正如@Dylan 所指出的,您必须使用 /deep/
来更改子组件中的 CSS.这是我一直在寻找的答案:
As @Dylan pointed out, you have to use /deep/
to alter the CSS within the child compoenets. Here is the answer I was looking for:
:host/deep/md-input-container .mat-input-wrapper
这篇关于覆盖 Angular 组件中的 Angular Material 样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!