Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Center image in Bulma

Tags:

bulma

Is there a way to horizontally centered an image inside a card?

I have the following

  <div class='column is-one-quarter has-text-centered'>     <div class='card equal-height'>       <div class='card-content'>         <figure class='image is-64x64'><img src='...'></figure>       </div>     </div>   </div> 

and I cannot center the image. I have tried to add is-centered both to the figure and to the parent div but nothing changes.

Thanks.

like image 277
Sig Avatar asked Jan 16 '18 09:01

Sig


People also ask

How do you center an image in Bulma?

Change the display property of card-content to flex by using the .is-flex modifier. Now you can use flexbox properties to horizontally center the figure .

How do you center vertically Bulma?

To align your columns vertically, add the is-vcentered modifier to the columns container. Second column with more content. This is so you can see the vertical alignment.

Is Bulma one quarter?

is-two-thirds. is-half. is-one-third. is-one-quarter.


1 Answers

Make the figure tag an inline-block and assign has-text-centered to the parent tag. Advantage is no custom code needed.

<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.6.2/css/bulma.min.css" rel="stylesheet"/>  <div class='column is-one-quarter'>    <div class='card equal-height'>      <div class="card-image has-text-centered">          <figure class="image is-64x64 is-inline-block">              <img class="is-rounded" src="https://unsplash.it/64"/>          </figure>      </div>      <div class='card-content'>        <!-- other content here -->      </div>    </div>  </div>
like image 190
Merbin J Anselm Avatar answered Sep 30 '22 18:09

Merbin J Anselm