我知道如何将背景图像添加到绘图对象,但是,是否可以为html.Div或html.H1添加背景图像?
答案 0 :(得分:2)
这是一个有效的示例,展示了如何使用内联样式添加background-image
。
import dash
from dash.dependencies import Input, Output
import dash_core_components as dcc
import dash_html_components as html
from pandas_datareader import data as web
from datetime import datetime as dt
import plotly.graph_objs as go
app = dash.Dash()
app.layout = html.Div(children=[
html.H1('Hello Dash', style={'background-image': 'url(https://upload.wikimedia.org/wikipedia/commons/2/22/North_Star_-_invitation_background.png)'})
])
if __name__ == '__main__':
app.run_server(debug=True)