Wednesday, 20 May 2020

Angular - CSS style not applying on angular directive

Hello Friends,


In this article, I will explain how to solve CSS style not applying on the angular directive 

In the last week, I was working with one directive where  CSS style was not applying on the angular directive 





Solution 1. Please add /deep/ to your CSS class 

Solution 2 We should use::ng-deep instead of /deep/ which seems to be deprecated.

Usually /deep/ “shadow-piercing” combinator can be used to force a style down to child components. We have another option called::ng-deep.

since /deep/ combinator has been deprecated, it is recommended to use::ng-deep

Please find the below example. This class will be applied to child component


Example
.overview {
    ::ng-deep {
        p {
            &:last-child {
                margin-bottom: 0;
            }
        }
    }
}

Hope this helped you to solve your error
Happy Programming!!
Don’t forget to leave your feedback and comments below!
If you have any query mail me to Sujeet.bhujbal@gmail.com     
Happy programming!!
Don’t forget to leave your feedback and comments below!
Regards
Sujeet Bhujbal
--------------------------------------------------------------------------------
------------------------------------------------------------------------------


0 comments:

Post a comment