【发布时间】:2021-02-15 10:57:33
【问题描述】:
我想改变下拉列表中文字的背景和颜色,但是背景只在主线改变,而展开列表中的文字颜色则相反。 我怎么解决这个问题? 如何更改悬停时的背景? 如何正确注册 Dash 的伪类,例如 a: hover?
import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output
app = dash.Dash(__name__)
style = {'background': '#111', 'color': 'blue', 'textAlign': 'center'}
dropdown_style = {'color':'red', 'width': '300px', 'background': '#777'}
upload_div = html.Div([
dcc.Dropdown(
id='upload_id',
options=[{'label': i, 'value': i} for i in ['a', 'b']],
value='a',
style = dropdown_style
),
html.Div(id='container')])
@app.callback(
Output('container', 'children'),
Input('upload_id', 'value')
)
def update_uploads(upload):
return upload
app.layout = html.Div(id='body', children=upload_div, style=style)
app.run_server()
【问题讨论】:
标签: python html css plotly plotly-dash