gpt4 book ai didi

python - 在 Dash-Plotly 中调整下拉菜单选项的宽度

转载 作者:行者123 更新时间:2023-12-04 12:20:41 25 4
gpt4 key购买 nike

我正在尝试基于 Plotly 在 Python 中使用 Dash 构建一个应用程序。我很难调整下拉菜单选项的宽度。我在下面附上了代码和图片。我希望下拉选项的宽度与菜单宽度相同。
enter image description here

app.layout = html.Div(children=[
html.H1(children='Welcome to Portfolio Construction Engine!'),
html.Div(children='What would you like to do?', style={
'font-style': 'italic',
'font-weight': 'bold'
}),
html.Div([
dcc.Dropdown(
id='demo-dropdown',
options=[
{'label': 'Upload Scores', 'value': 'upload_scores'},
{'label': 'Analyze Portfolios', 'value': 'analyze_portfoliio'},
{'label': 'Generate Data for IC Engine', 'value': 'gen_data_ic_engine'}
],
placeholder='Select a task...',
style={
'width': '50%'
}
),
html.Div(id='dd-output-container')
])
])

最佳答案

虽然正确放置 width: 50%要更改下拉组件的宽度,您已将其放置在内部组件而不是父 Div 中。

app.layout = html.Div(
children=[
html.H1(children="Welcome to Portfolio Construction Engine!"),
html.Div(
children="What would you like to do?",
style={"font-style": "italic", "font-weight": "bold"},
),
html.Div(
[
dcc.Dropdown(
id="demo-dropdown",
options=[
{"label": "Upload Scores", "value": "upload_scores"},
{"label": "Analyze Portfolios", "value": "analyze_portfoliio"},
{
"label": "Generate Data for IC Engine",
"value": "gen_data_ic_engine",
},
],
placeholder="Select a task...",
# style={"width": "50%"}, NOT HERE
),
html.Div(id="dd-output-container"),
],
style={"width": "50%"},
),
]
)

关于python - 在 Dash-Plotly 中调整下拉菜单选项的宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62988494/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com