[英]Set common background for all components in Angular 6
我試圖在所有組件上使用背景(包含圖像和顏色),並將其代碼放入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文件設置背景。 其他頁面將從主布局視圖呈現它。
會看起來像這樣:
<html>
<head>
<style>background-color: #color_id</style>
</head>
<body>
{{{body}}}
</body>
</html>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.