我的儀表板有多個頁面,每個頁面都包含頂部導航欄和容器。
在我的 style.css 檔案中,只有一個 body 可以更改 body 的背景顏色,目前我更改了容器的背景顏色。
我的問題是:從一頁切換到另一頁時,是否可以更改全身的背景顏色?
page1_layout = html.Div([navbar_page1, container_page1])
page2_layout = html.Div([navbar_page2, container_page2])
container_page1 = html.Div([top_info_page1, grid_container_page1]
container_page2 = html.Div([top_info_page2, grid_container_page2]
:root {
--text-color: #798d8f;
--tab-color: #212529;
}
/* Add background color to entire app */
body {
background-color: var(--text-color);
}
#container-page1 {
margin-left: 1%;
margin-right: 1%;
}
#container-page2 {
margin-left: 1%;
margin-right: 1%;
background-color: #DADADA;
uj5u.com熱心網友回復:
你可以給 body 元素一個 class/id 并設定特定的 class/id 背景顏色
<body id="page1">content</body>
<body id="page2">content</body>
body{
background: red;
}
#page2{
background: blue !important;
}
uj5u.com熱心網友回復:
試試這個:
document.body.style.backgroundColor= 'the color';
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/468659.html
上一篇:重疊兩個盒子
