简体   繁体   English

如何设置角度为4或5的组件背景颜色?

[英]How to style component background-color in angular 4 or 5?

How to style a component in angular? 如何在角度设置组件样式? I use angular 5 and I tried this: 我使用角度5,我试过这个:

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

And this: 还有这个:

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

Both approaches don't seem to work. 这两种方法似乎都不起作用。

You also need to set the display property to something like block . 您还需要将display属性设置为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). 默认情况下, display属性是inline的(您可以在开发人员工具中看到这一点等)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM