在Angular组件中覆盖Angular材质样式 [英] Override Angular Material style in Angular component

查看:249
本文介绍了在Angular组件中覆盖Angular材质样式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Angular组件中使用材质2 <md-input-container>.我想覆盖其中一个类在角材料中定义的.mat-input-wrapper.但是我只想覆盖该组件,并且覆盖不应影响页面中的其他组件.

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材质样式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆