【发布时间】:2019-09-24 09:10:02
【问题描述】:
我正在构建一个仪表板应用程序,它是DatePickerSingle 和RadioItems。我已将所有内容置于中心位置,使其看起来像是在手机上。
这是我的 css,用于将我的应用中的所有内容居中:
html * {
width: 100%; max-width: 500px; margin: auto;
}
如下图所示,每周的两天没有显示,将用户带到下个月/上个月的箭头已移动。
这是 DatePickerSingle 的 CSS:
.DateInput{
margin: 0;
padding: 0;
background: #fff;
position: relative;
display: inline-block;
width: 100%;
vertical-align: middle;
}
.DayPicker {
text-align: center;
}
.DayPicker_transitionContainer {
position: relative;
overflow: None;
border-radius: 3px;
}
这是我的RadioItems 居中后的样子:
--RadioItems 没有 css --
但是,我试图通过这样做来解决它:
import dash_core_components as dash_core
dash_core.RadioItems(id="gender_input",
options=[
{'label': 'Male', 'value': 'male'},
{'label': 'Female', 'value': 'female'}
],
style={"align": "left"})
只有当我把所有东西都放在中心时才会出现这些问题。显然,我不擅长 css,除了我上面提供的 css 之外,一切都在默认样式下。
请帮我解决这些问题。
编辑 2(根据coralvanda 的回答):
我已经删除了 *html 的 css 并将您建议的内容放在孩子之后的代码中,这就是现在的样子:
现在,仍然没有显示文本之前的两个Divs 和一个Hr(请参阅滚动条)。
编辑 3(建议单独 Divs):
这就是现在的样子:
代码是:
app.layout = dash_html.Div(children=[
# radio button with no centering
dash_html.H4("Do you take anti-hypertensive medication"),
dash_core.RadioItems(className='Radio-button',
id="hypertensive_input",
options=[
{'label': 'Yes', 'value': 'yes'},
{'label': 'No', 'value': 'no'}
]),
# radio button with centering
# text appears after the radio inputs, when it should be o
dash_html.Div(children=[
dash_html.H4("Do you take anti-hyperlipedemic medication"),
dash_core.RadioItems(className='Radio-button',
id="hyperlipedmic_input",
options=[
{'label': 'Yes', 'value': 'yes'},
{'label': 'No', 'value': 'no'}
])
], style=dict(display='flex', justifyContent='center')),
# an input form with no styling
dash_html.H4("Enter your Insulin"),
dash_core.Input(className="input-form", id="insulin_input", placeholder='e.g.: 19.3, 25, 38.2', type='number')
])
【问题讨论】:
标签: python python-3.x plotly-dash