css - 由于 _reboot.scss,无法将背景图像设置为特定的 Angular 组件

标签 css angular bootstrap-4

我正在尝试使用以下代码将 background-image 设置为我的特定 Angular 组件:

body { 
        background-image: url(...); 
        background-size: cover;
        background-repeat: no-repeat; }

这段代码放在Angular组件的.css文件中。

但是,在浏览器控制台中,我注意到 _reboot.scss 类(可能来自 Bootstrap)正在将我上面的代码片段覆盖为默认背景颜色。

我已经尝试了几乎所有方法,更改背景图像的唯一方法是使用 F12 模式在浏览器中修改 _reboot.scss 类。

最佳答案

您可以将您的代码设置为:

._reboot.scss { 
        background-image: url(...); 
        background-size: cover;
        background-repeat: no-repeat; }

覆盖 Bootstrap。

或者,给你的 css !important :

body { 
        background-image: url(...)!important; 
        background-size: cover;
        background-repeat: no-repeat; }

关于css - 由于 _reboot.scss,无法将背景图像设置为特定的 Angular 组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54731711/

相关文章:

css - Bootstrap 表的自定义加载消息(替换 "Loading, please wait...")

angular - 使用 Angular 库作为 git 依赖项

css - 有没有办法让网格布局中的 child 使用 CSS 拉伸(stretch)全宽

css - Less:导入带有 url 的另一个 css 的 import css 不起作用

html - 为图像创建 div 类

html - 溢出 :visible not working in <th> IE 7, 8

javascript - 如何在 Angular 6 的 Angular Material 对话框中将数据传递给 afterClosed()

image - Bootstrap 4 在导航栏中对齐 img 和文本

twitter-bootstrap - Bootstrap javascript 加载但不工作

html - 溢出导致整个页面滚动