Style html,body from web component (Angular 2)

前端 未结 10 1831
南笙
南笙 2020-12-03 00:39

I\'m working on a LoginComponent in Angular 2 that should \"restyle\" the html and body tags, so I can put in a background image speci

10条回答
  •  猫巷女王i
    2020-12-03 01:05

    You need to change the way your component serves css using ViewEncapsulation. By default it's set to Emulated and angular will

    add an attribute containing surrogate id and pre-process the style rules

    To change this behavior import ViewEncapsulation from 'angular2/core' and use it in component's metadata:

    @Component({
      ...
      encapsulation: ViewEncapsulation.None,
      ...
    })
    

提交回复
热议问题