How to inherit css styles in child component from parent in Angular 5

前端 未结 3 826
天涯浪人
天涯浪人 2021-02-18 17:19

I have a parent component inside which I have a child component. The parent component have some css classes, where child component extends them. I tried to use :host as looking

3条回答
  •  遇见更好的自我
    2021-02-18 17:43

    With ::ng-deep, styles will be applied to the current component, but also trickle down to the components that are children to the current component in the component tree.

    Example:

    :host ::ng-deep app-child-component {
           color:yellow;
         }
    

    A good resource - Styles Between Components in Angular 2+

提交回复
热议问题