Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bulma: How do you center a button in a box?

Tags:

html

css

bulma

<div class="box">  <button class="button">Center me</button> </div> 

<button class="is-center"> is not working.

like image 376
Dazzle Avatar asked Mar 03 '17 15:03

Dazzle


People also ask

How do I center a button within a container?

Use the following steps to center align a button in a div container: Create a div container. Insert the button tag. In the CSS for the div set the text-align to center.

How do you center an element in a box?

Center Align Elements To horizontally center a block element (like <div>), use margin: auto; Setting the width of the element will prevent it from stretching out to the edges of its container.

How do I center a button in form element?

You can center a block level element by setting margin-left and margin-right to auto . We can use the shorthand margin: 0 auto to do this. (This also sets margin-top and margin-bottom to zero.)


2 Answers

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>
like image 104
Mohammad Usman Avatar answered Oct 02 '22 17:10

Mohammad Usman


You can also try:

<div class="columns is-centered">     <div class="column is-half">         <button class="button">Center me</button>     </div> </div> 
like image 32
Réda Nefzi Avatar answered Oct 02 '22 18:10

Réda Nefzi