Search code examples
htmlcssbulma

Center content in bulma column


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;
}

Solution

  • <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