prime ng styles not applying angular2

前端 未结 7 1945
予麋鹿
予麋鹿 2021-01-11 20:24

Hi I just started working with angular 2. I found this library PrimeNG, I followed this tutorial: http://blog.davincisoftware.sk/primeng-web-component-framework-based-on-ang

7条回答
  •  轮回少年
    2021-01-11 20:33

    I wouldn't turn off ViewEncapsulation as your styles could bleed out and potentially cause issues in the rest of your application.

    I'd recommend using the /deep/ selector to force a style down through the child component tree. This can be applied on a Class by Class basis or to multiple Classes, as below.

    A single Class

    :host #{"/deep/"} .yourStyle1 {
        color: #ffffff; 
    }
    

    Multiple Classes

    :host #{"/deep/"} {
    
         .yourStyle1 { color: #ffffff; }
    
         .yourStyle2 { color: #000000; }
    }
    

    More Info: https://angular.io/docs/ts/latest/guide/component-styles.html

提交回复
热议问题