14

I have multiple columns. Each column contains a circle in the CSS within a font awesome icon centered in it. Now I wanna make align the circle itself in the middle of the column. However, it keeps staying on the left while the text itself gets centered.

HTML

<div class="features">
  <div class="container">
    <div class="columns is-mobile ">
      <div class="column">
        <div class="community">
          <font-awesome-icon col size="2x" :icon="['fas', 'tasks']" />
        </div>
        Features
      </div>
    </div>
  </div>
</div>

CSS

.features {
  background: #2a3a4c;
  height: 200px;
}

.community {
  width: 5rem;
  height: 5rem;
  background: linear-gradient(135deg, #b15757 0%, #b96868 100%);
  border-radius: 100%;
  text-align: center;
  vertical-align: middle;
  display: table-cell;
}
niko
  • 153
  • 1
  • 2
  • 5
  • Did you forgot to add css code for drawing a circle? Try removing text-align and add margin:0 auto; for the .community css or do it for .column if still not centered.. – boateng May 17 '18 at 19:08

3 Answers3

29

<div class="columns is-centered">...</div> centeres the column. You have to set a width for the column inside to make it work. The class is-narrow takes only the space it needs.

Example

.features {
  background: #2a3a4c;
}

.features .columns {
  height: 200px;
}

.circle {
  width: 5rem;
  height: 5rem;
  background: linear-gradient(135deg, #b15757 0%, #b96868 100%);
  border-radius: 100%;
  text-align: center;
  vertical-align: middle;
  display: table-cell;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css" rel="stylesheet" />
<div class="features">
  <div class="container">
    <div class="columns is-centered is-vcentered is-mobile">
      <div class="column is-narrow has-text-centered">
        <div class="circle">
          <font-awesome-icon col size="2x" :icon="['fas', 'tasks']" />
        </div>
        Features
      </div>
    </div>
  </div>
</div>

More information: Bulma columns sizes

7

This will make your text, buttons or images centred

Add to the HTML content:

class="has-text-centered"

And if you want file upload input centred

Add to the HTML content:

class="is-centered"
  • 2
    It would be nice if you edited your answer to show some more effort (small explanation, specify where to put it, etc.). Also see [answer] – fuggerjaki61 Aug 13 '20 at 18:11
0

Do you need to use table-cell for .community? It didn't appear to be doing anything. If not you can change

.community {
  width: 5rem;
  height: 5rem;
  background: linear-gradient(135deg, #b15757 0%, #b96868 100%);
  border-radius: 100%;
  text-align: center;
  vertical-align: middle;
  display: table-cell;
}

to

.community {
  width: 5rem;
  height: 5rem;
  background: linear-gradient(135deg, #b15757 0%, #b96868 100%);
  border-radius: 100%;
  text-align: center;
  margin: 0 auto;
}

and add

.column {
  text-align: center;
}

That will make everything centered.

You can see the working example at https://codepen.io/anon/pen/odQGoj

PS you're missing a closing </div> for <div class="features">

Axion
  • 682
  • 4
  • 20