Marco Jr
Marco Jr

Reputation: 6806

Angular 5 - Change body and html5 style

This used to work before...now it's not working anymore. Maybe some concept change on Angular 5 ? I just need to set the style properties of the body and html elements. Any clue ?

app.component.scss

 body, html {
  width: 100%;
  height: 100%;
  margin: 0;
  font-family: verdana !important;
  background-color: blue;
 }

and this:

 import { Component } from '@angular/core';

@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
  title = 'app';
}

Upvotes: 1

Views: 1235

Answers (1)

callback
callback

Reputation: 4122

By default all angular styles are scoped to their component so adding styles to html/body tags from inside the app component (or any component) won't work.

Add those to the styles.scss file. Or if you insist you can try adding this to your @component({ ..., encapsulation: ViewEncapsulation.None })

Upvotes: 6

Related Questions