CSS is not working in my angular component

后端 未结 3 571
一整个雨季
一整个雨季 2021-02-01 15:28

I am trying to make a simple Angular4 web app that will show and X or O depending on what the rating is. I do not see the X or O in my web app.

The CSS classes in my rat

3条回答
  •  梦如初夏
    2021-02-01 16:01

    I believe the problem you’re having is because you’re declaring the styleUrls on the parent component and due to encapsulation they are not available in the child component. You have to move it to the rating component.

    In case you want to keep it on the level you currently have you need to make the view encapsulation none on the rating component.

    selector: 'rating',
    encapsulation: ViewEncapsulation.None
    

    I believe you also are misusing the content css property. You need to used either the ::before or ::after pseudo elements

    .star.star-full-icon::after{
        content:'X';
    }
    .star.star-empty-icon::after{
        content:'O';
    }
    

提交回复
热议问题