angular - 为 Angular 6 中的所有组件设置通用背景

标签 angular css background

我试图在所有组件上设置背景(包括图像和颜色),并将其代码放入 styles.css 中。它出现在 AppComponent 主页面上,但呈现的任何其他组件出现在该页面之上,并用它们自己的白色背景覆盖背景。所以现在我将背景应用到每个组件并调整顶部位置。

有没有更简单、更有效的方法来做到这一点?

这是我在我的组件中应用的一些 CSS 代码。

a.component.css

.bg {
   background: rgba(240, 240, 240, 1) url('src/assets/images/background.png');
   background-repeat: no-repeat;
   background-position: 60% -312px;
   background-size: 2874px 818px;
}

b.component.css

.bg {
   background: rgba(240, 240, 240, 1) url('src/assets/images/background.png');
   background-repeat: no-repeat;
   background-position: 60% -482px;
   background-size: 2874px 818px;
}

最佳答案

如果您在这种情况下制作节点应用程序,您只需为 main.handlebars 文件设置背景即可。其他页面将从主布局 View 中呈现它。

看起来有点像这样:

<html>
 <head>
  <style>background-color: #color_id</style>
 </head>
 <body>
  {{{body}}}
 </body>
</html>

关于angular - 为 Angular 6 中的所有组件设置通用背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52811142/

相关文章:

jquery - 在ajax请求后重新初始化Jquery Mobile的所有元素?

javascript - 如何在滚动时更改背景

css - 背景大小不起作用

iPhone 固定位置 UITableView 背景

angular - 条件边框颜色

python - 从 Django 中的模型链接 2 个字段

angular - ng2 验证在 Angular2 Angular 种子中不起作用

html - ul 不拉伸(stretch)宽度来填充 div 的空间

javascript - Angular2 奇怪的硬编码对象与 http.get 对象问题

angular - 在 angular2 中找不到名称 'jquery'