gpt4 book ai didi

angular - 如何覆盖组件中的body属性?

转载 作者:行者123 更新时间:2023-12-02 20:47:40 25 4
gpt4 key购买 nike

我有默认的 style.sass 文件,其中包含 SAP 的常见样式。

该文件包含 body {} 的样式。

如何从任何组件覆盖此 CSS 属性?例如我需要更改组件登录中主体的背景颜色。

最佳答案

为此,您需要设置ViewEncapsulation.None:

import {..., ViewEncapsulation} from '@angular/core';

@Component({
selector: 'my-app',
encapsulation: ViewEncapsulation.None,

该组件内的所有样式都将添加到全局样式中。

这是 docs 的引用:

None means that Angular does no view encapsulation. Angular adds the CSS to the global styles. The scoping rules, isolations, and protections discussed earlier don't apply. This is essentially the same as pasting the component's styles into the HTML.

关于angular - 如何覆盖组件中的body属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45286416/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com