我正在使用 dash(用于制作儀表板的 python 庫)并且我遇到了引導程式組件的問題。我不能從容器中排除右邊距。我正在使用這個:class_name='m-0'在容器類上。也已經嘗試使用style={'margin': '0px'},但保持相同的方式。
# Layout
app.layout = dbc.Container(children=[
dbc.Row([
dbc.Col([
html.Div(children=[
html.H5(children='BAJA UEA'),
html.H6(children="Visualiza??o dos dados da telemetria"),
]),
]),
dbc.Col([
dcc.Dropdown(['2400', '4800', '9600', '115200'], id='baudrate-dropdown', value='9600',
placeholder='Baudrate', style={'width': '150px'}),
dcc.Dropdown(portList, id='ports-dropdown', value='portList[0]', placeholder='COM Ports',
style={'width': '150px'}),
dbc.Button('Connect', id='connect-button', style={'width': '150px'}),
], class_name='d-flex p-3 align-items-center justify-content-evenly'),
]),
dbc.Row([
dbc.Col([
dcc.Graph(
id='graph_temperature',
figure=graph_temperature
),
dcc.Graph(
id='graph_velocidade',
figure=graph_velocidade
),
dcc.Graph(
id='graph_PRM',
figure=graph_PRM
),
dcc.Graph(
id='graph_ACC',
figure=graph_ACC
)
]),
dbc.Col([
])
])
], class_name='m-0')

uj5u.com熱心網友回復:
您的問題很難診斷,因為您沒有提供我們可以運行以演示該行為的最小示例。
從您提供的代碼片段來看,最可能的解釋是您沒有使用流體容器,因此您的容器將具有引導檔案中規定的固定寬度。
fluid=true您可以通過設定容器定義(此處為檔案)來切換到流體容器,例如
app.layout = dbc.Container(
fluid=True,
children=[ ... ]
)
在風格上,我還建議使用Bootstrap Utilities來管理邊距、填充、彈性等,而不是直接對 CSS 進行編碼。
uj5u.com熱心網友回復:
嘗試這個
class_name='mx-0 w-100'
https://getbootstrap.com/docs/5.1/utilities/spacing/
https://getbootstrap.com/docs/5.1/utilities/sizing/
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/533796.html
