如何更改< body>子组件的标签样式? [英] How to change <body> tag style from child component?
本文介绍了如何更改< body>子组件的标签样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在index.html中有这个:
I have this in index.html:
<body class="light-gray">
<app-root></app-root>
<div id="preloader">
<div></div>
</div>
</body>
在应用程序根目录中,我有这个:
In app-root i have this:
<laylout></laylout>
内部布局我有一个组件,我想在 scss
中更改索引的主体.有什么建议我该怎么做?
Inside layout i have one component where in scss
i want to change body on index. Any suggestion how can i do that?
.light-gray{
background: red!important;
}
我尝试过:host
,但这不是主要的父母,我需要类似的东西::host:host:host
.主机的主机:)
I tried :host
but this is not main parent i need something like: :host :host :host
. Host of host of host :)
推荐答案
使用:: ng-deep,如下所示:
Use ::ng-deep, like so:
CSS
::ng-deep .light-gray{
background-color: red;
}
使用ViewEncapsutation.无:
Use ViewEncapsutation.None:
CSS
.light-gray{
background-color:red
}
课程:
import { ViewEncapsulation } from '@angular/core';
...
@Component({
...
encapsulation: ViewEncapsulation.None
这篇关于如何更改< body>子组件的标签样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文