python - Plotly Dash 中心 dcc.输入文本字段

标签 python user-input centering plotly-dash

我在弄清楚将 dash_core_components.Input 文本字段置于页面中间所需的样式参数方面遇到了很多困难。

import dash
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output

text_input_style = {'justify-content': 'center', 'align-items': 'center'}
bucket_select = html.Div([
    html.Label('S3 bucket:'),
    dcc.Input(id='bucket_name', placeholder='Enter input here...', 
              value=None, type='text', 
              style={'width': '10%', 'textAlign': 'center'}),
    html.Div(id='bucket_out')
], style=text_input_style)

app = dash.Dash(__name__)
app.layout = html.Div(bucket_select)
app.run_server(port=5555)

到目前为止我已经尝试过:

  • 'justify-content': 'center'
  • 'align-items': 'center'
  • '显示':'flex'
  • 'padding-left':'45%'

我尝试在文档中搜索 dcc.Input,但找不到任何 style 信息。

最佳答案

This is where您可以找到 dcc.Input 的各种 Prop 。您可以将包含的 div 设置为具有 display='flex'justifyContent='center'。示例:

html.Div(
    children=[dcc.Input()],  # fill out your Input however you need
    style=dict(display='flex', justifyContent='center')
)

关于python - Plotly Dash 中心 dcc.输入文本字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57367419/

相关文章:

python - 如果字典中的键在键存在时返回 false

html - 如何使用 flexbox 将列表定位在中心?

html - 居中缩略图

java - 如何使用用户输入查找数组中的范围?

html - 将 <div> 在页面上垂直和水平居中的最佳方式?

python - 如何更改 `setup.py test` 以使用不同的 Pypi 服务器?

Python,SQL : INSERT INTO. ..使用字典进行重复更新

python - 如何根据另一列的过滤器或条件删除数据帧的重复行?

c++ - 如何让 cin 循环在用户按下回车键时停止?

java - 用户输入无法解析