使用 Dash 和 Plotly 构建仪表板
Alex Scriven
Data Scientist
$$
大多数网站都有 CSS 文件:
style 属性
CSS 也可用于单个 HTML 元素
style 属性"property:value; property:value;"

<h1>Welcome to the website!</h1>
<h2 style="font-size:50px;color:red">
Enjoy your stay!
</h2>

我们可以在在线网站上临时编辑 CSS

Dash 组件的 style 参数
之前在 Dash 组件中的代码:
app.layout = [
html.H1('Welcome to the website!'),
html.H2('Text',
style={'font-size':'50px',
'color':'red'})
]
CSS 可用于设置:
background-color)color)
两者均接受字符串(如 'red')或 RGB 代码(如 'rgb(0,0,255)' 表示蓝色)

CSS 可通过 width 和 height 设置尺寸
app.layout = [
# 添加并调整公司徽标大小
html.Img(src=logo_link,
style={'width':'250px', 'height':'250px'})
]
app.layout = [
# 添加并调整公司徽标大小
html.Img(src=logo_link,
style={'width':'50%', 'height':'50%'})
]
使用 Dash 和 Plotly 构建仪表板