Rasmus Rajje Josefsson Rasmus Rajje Josefsson - 1 year ago 112
CSS Question

Use full width of one component Angular2

I wonder if anyone know how you set full width of one component with an background in Angular 2. Just want to use it on the home screen.

Following changes all the components so that doesn't work.

encapsulation: ViewEncapsulation.None,

Answer Source

If you are using ViewEncapsulation.None, then you can do it like this:

  selector: 'my-component',
  providers: [],
  template: `
      'my-component { float:left;width:100%;padding:5px;background:#ccc;}',
      'html, body {margin:0px; }' 
  encapsulation: ViewEncapsulation.None

See Plunker here: https://plnkr.co/edit/b3jtpO5TAkV4eK0ZuR1k?p=preview

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download