将背景图片添加到 Dash-plotly 中的 html.div [英] Add background image to html.div in Dash-plotly

查看:92
本文介绍了将背景图片添加到 Dash-plotly 中的 html.div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何将背景图像添加到绘图对象中,但是,是否可以为 html.Div 或 html.H1 添加背景图像?

I know how to add a background image to a plotly graph object, however, is it possible to add background image for html.Div or html.H1 ?

推荐答案

这是一个演示如何使用内联样式添加 background-image 的工作示例.

Here is a working example demonstrating how to add a background-image using inline styles.

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)

这篇关于将背景图片添加到 Dash-plotly 中的 html.div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆