将 ipywidget 按钮居中对齐

3

我想要将ipywidget函数中的按钮对象居中对齐。以下是我使用的代码示例:

bt = widgets.Button(layout=Layout(width='180px'),style = 
    {'description_width': '25%'})
b_config_save = widgets.Button(
    description="Save",
    layout=bt.layout,
    style=bt.style,
    button_style='primary'
)
2个回答

10

按照下图所示使用flexbox布局。

btn = widgets.Button(description="Save")
box_layout = widgets.Layout(display='flex',
                flex_flow='column',
                align_items='center',
                width='50%')
box = widgets.HBox(children=[btn],layout=box_layout)
display(box)

文档已经移动,链接不再指向那里。新链接 - Battleman

0

尝试使用表格,也许你可以在这里找到一些帮助。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接