<div class="box">
<button class="button">Center me</button>
</div>
<button class="is-center">
is not working.
<div class="box">
<button class="button">Center me</button>
</div>
<button class="is-center">
is not working.
Yes, there is a native way.
Bulma offers has-text-centered
class for centering text, inline
and inline-block
elements.
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>
button
is an inline element and to affect an inline element we need to add property on parent. However, you can create a custom class and add it on button if there are a lot of buttons in your application. Here is an Example –
Hygrophilous display: table
makes it "behave like a table". Why does that work? –
Clockwise display: table
will make element to behave like a block level element. And also width of element will depend on its content. So element will remain center horizontally. –
Hygrophilous You can also try:
<div class="columns is-centered">
<div class="column is-half">
<button class="button">Center me</button>
</div>
</div>
Quick fix: wrap the button in a div with style="text-align:center;"
<div style="text-align: center;">
<button class="button is-success">Center me</button>
</div>
text-align: center
, for which specifically the Bulma class is .has-text-centered { text-align: center !important; }
. BTW framework such as Bulma, Bootstrap etc. regularly use !important
so that the framework's styling takes precedence –
Midgut © 2022 - 2024 — McMap. All rights reserved.