Sass 无法通过页面css文件向“body”标记添加值
在我的angular应用程序中,我向body添加了一个类名,如:Sass 无法通过页面css文件向“body”标记添加值,sass,angular5,Sass,Angular5,在我的angular应用程序中,我向body添加了一个类名,如: ngOnInit() { this.store.updatePageClass('page-quoteCart'); } 在page.css上,我编写了一个类,如: @media only screen and (min-width: 320px) and (max-width: 620px) { .page-quoteCart{ border:2px solid red; //but n
ngOnInit() {
this.store.updatePageClass('page-quoteCart');
}
在page.css上,我编写了一个类,如:
@media only screen and (min-width: 320px) and (max-width: 620px) {
.page-quoteCart{
border:2px solid red; //but not added
}
}
但是没有得到输出。如果我在assets
文件夹中使用style.css编写相同的代码,则可以正常工作。这里的问题是什么
如何根据页面编写css?请在html中添加
封装:ViewEncapsulation.None
。
它会解决你的问题
例如,在更新封装:ViewEncapsulation.None
后,组件文件将如下所示:
import { Component, ViewEncapsulation } from '@angular/core';
@Component({
selector: 'xxxxx',
templateUrl: 'xxxxx.html',
styleUrls: ['xxxx.scss'],
encapsulation: ViewEncapsulation.None
})