Angular Material2 theming - how to set app background?

后端 未结 10 1637
别那么骄傲
别那么骄傲 2020-12-04 14:24

I am building an angular2 app using angular material2. I am trying to set the background of my application \"the correct way\", but I can\'t figure out how.

I found

10条回答
  •  独厮守ぢ
    2020-12-04 14:48

    for extra solution if previous didn't work i angular material 2 working with encapsulation style so whatever you gonna do you can't customize angular material component from outside so an ideal solution for that i always use try this

    1- you can use this hack that gonna give you possibilities to customize angular material component if you want to by set ViewEncapsulation.None

    //test.component.ts
    import { ViewEncapsulation } from '@angular/core';
    @Component({
      selector: 'app-test',
      templateUrl: '.....',
      styleUrls: ['....'],
      encapsulation: ViewEncapsulation.None
    })
    

    or

    2- if you want just to change background you can simple try this

    //style.css (main style file)
    html, body {
      background-color: #fafafa;
    }
    

    this gonna change the whole background color of all your app

提交回复
热议问题