5

How to style a component in angular? I use angular 5 and I tried this:

:host {
    background-color: green;
    size: 200px 200px;
}

And this:

app-root {
    background-color: green;
    size: 200px 200px;
}

Both approaches don't seem to work.

  • [Angular 2: How to style host element of the component?](https://stackoverflow.com/questions/32853924/angular-2-how-to-style-host-element-of-the-component) – HDJEMAI Dec 23 '17 at 16:01

1 Answers1

13

You also need to set the display property to something like block. This can be seen in the example from the docs:

:host {
    background-color: green;
    size: 200px 200px;
    display: block;
}

The display property is inline by default (you can see this in the developer tools, etc).

Kirk Larkin
  • 84,915
  • 16
  • 214
  • 203