【发布时间】:2022-01-04 16:08:13
【问题描述】:
对于一个项目,我正在尝试使用 Dash 创建一个 Web 应用程序仪表板。
因为我有多个具有不同布局的网络应用程序版本,我希望我的应用程序的每个版本都指向一个特定的 .css 文件,存储在我的资产文件夹中,以供使用。
我不想删除用于不同版本但位于同一项目文件夹中的其他 .css 文件。其他的.css文件基本上应该忽略。
project
│ app.py
│ app_custom.py
│
└───/assets
│ style.css
│ custom_style.css
因此,如果我运行 app_custom.py,我希望应用只使用 style_custom.css。
在我的代码下面:
# external css/js files are loaded before .css files in /assets
external_stylesheets = [dbc.themes.BOOTSTRAP,
{
"href": "https://fonts.googleapis.com/css2?"
"family=Lato:wfght@400;700&display=swap",
"rel": "stylesheet",
}
]
app = Dash(__name__, external_stylesheets=external_stylesheets)
app.index_string = '''
<!DOCTYPE html>
<html>
<head>
{%metas%}
<title>{%title%}</title>
{%favicon%}
{%css%}
</head>
<body>
<div>My Custom header</div>
{%app_entry%}
<footer>
{%config%}
{%scripts%}
{%renderer%}
</footer>
<div>My Custom footer</div>
</body>
</html>
'''
app.layout = html.Div(
dbc.Button("Success", color="success", className="mr-1")
)
if __name__ == "__main__":
app.run_server()
【问题讨论】:
标签: python css plotly-dash