7

我对如何在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'
       ),
     ]
    ),
4

2 回答 2

2

我认为您需要的是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'
   ),
 ]
),
于 2020-03-31T18:35:20.803 回答
-2

我想我想通了。它看起来正确:

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'
于 2018-02-13T20:00:29.280 回答