Html 布尔玛:你如何将一个按钮放在一个盒子里?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/42583298/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Bulma: How do you center a button in a box?
提问by Dazzle
<div class="box">
<button class="button">Center me</button>
</div>
<button class="is-center">
is not working.
<button class="is-center">
不管用。
回答by Mohammad Usman
Yes, there is a native way.
是的,有一种本地方式。
Bulma offers has-text-centered
class for centering text, inline
and inline-block
elements.
Bulma 提供has-text-centered
用于居中文本inline
和inline-block
元素的类。
You can use following code:
您可以使用以下代码:
<div class="box has-text-centered">
<button class="button">Center me</button>
</div>
Demo:
演示:
<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.3.2/css/bulma.css" rel="stylesheet"/>
<div class="box has-text-centered">
<button class="button">Center me</button>
</div>
回答by Dazzle
Quickfix: wrap the button in a div with style="text-align:center;"
快速修复:用 style="text-align:center;" 将按钮包裹在一个 div 中
<div style="text-align: center;">
<button class="button is-success">Center me</button>
</div>