Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply CSS on custom tag in Angular 2/5?

I've installed the Google ReCaptcha (ng-recaptcha) component to my app, and was wondering if there is a way to apply some styles to children elements of the generated, in my case, <re-captcha></re-captcha> element.

For example:

re-captcha{
    border: 1px solid #ccc; /*works*/
}

re-captcha div{
    border: 1px solid #ccc; /*doesn't work*/
} 

Could you please share some experience of achieving the desired result?

UPDATE:

The following works however, if set directly in DevTools...

re-captcha div{
    border: 1px solid #ccc; 
} 
like image 919
Emil Gurbanov Avatar asked Dec 18 '22 00:12

Emil Gurbanov


1 Answers

This is caused by the view encapsulation setting of the component.

You can use a /deep/ or ::ng-deep selector to target child components in Native or Emulated (which is default) modes, in which abbasak's answer will work.

like image 64
bc1105 Avatar answered Dec 28 '22 11:12

bc1105