简体   繁体   English

组件css / scss不会影响angular2中的元素类

[英]component css / scss is not affecting element class in angular2

I'm working on an angular 4 project and I'm trying to override css in a specific component. 我正在开发一个angular 4项目,并且尝试覆盖特定组件中的CSS。 My changes also show up after compiling but they are not affecting the element. 我的更改也会在编译后显示,但它们不会影响该元素。 The element sits in a parent component, but I already tried using :host. 该元素位于父组件中,但是我已经尝试使用:host。

Element: 元件: 元件

Generated CSS: 生成的CSS:

生成的CSS

I had this same problem and I found out you can style your children component from its parent. 我遇到了同样的问题,我发现您可以从其父级中为子级组件设置样式。 The generated css never match what you want. 生成的CSS永远不会符合您的要求。 See the picture. 看图片。 I solved it by passing a state info(expanded @input attr) to the child component and styling it according to this state value as so: 我通过将状态信息(扩展了@input attr)传递给子组件并根据该状态值来设置样式来解决了该问题:

Image illustrating my point 该图说明了我的观点

... ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM