我对如何在dash
中布局控件感到困惑。如何将dropdown
和datepicker
并排放在同一行?
html.Div(
[
html.Div(
[
dcc.Dropdown(id='dropdown',
options=[{'label': i, 'value': i} for i in all_options],
multi=False,
placeholder='Select Symbol...',
),
dcc.DatePickerSingle(
id='my-date-picker-single',
min_date_allowed=today,
max_date_allowed=today,
initial_visible_month=today,
date=today)
],
className='row'
),
]
),
答案 0 :(得分:0)
我认为您需要的是要并排显示的元素的style
选项。都使用style={'float': 'right','margin': 'auto'}
。
html.Div(
[
html.Div(
[
dcc.Dropdown(id='dropdown',
options=[{'label': i, 'value': i} for i in all_options],
multi=False,
placeholder='Select Symbol...',
style={'float': 'right','margin': 'auto'}
),
dcc.DatePickerSingle(id='my-date-picker-single',
min_date_allowed=today,
max_date_allowed=today,
initial_visible_month=today,
date=today
style={'float': 'right','margin': 'auto'}
)
],
className='row'
),
]
),
答案 1 :(得分:-1)
我想我明白了。它看起来是正确的:
html.Div(
[
dcc.Dropdown(id='dropdown',
options=[{'label': i, 'value': i} for i in all_options],
multi=False,
placeholder='Select Symbol...'
)
],
className='two columns'
),
html.Div(
[
dcc.DatePickerSingle(
id='my-date-picker-single',
month_format='Y-M-D',
min_date_allowed=today - timedelta(days=3),
max_date_allowed=today + timedelta(days=730),
initial_visible_month=today,
date=today),
html.Div(id='output-container-date-picker-single')
],
className='two columns'