-1

I'd like to somehow target the class in:

<i class="fas fa-tree fa-4x"></i>

and center the content horizontal

fas {
  align-content: center;
}

I can't figure something out though. Thank you in advance for any suggestions.

This is the context:

<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="col-md-4 mb-1">
  <i class="fas fa-tree fa-4x"></i>
  <h4 class="my-4" font-weight-bold>The Park</h4>
  <p>Text</p>
</div>
SMAKSS
  • 9,606
  • 3
  • 19
  • 34

1 Answers1

-1

First way: when you only want to center the icon.

.cutomsClass  {
  display: flex;
  justify-content: center;
  flex-direction: column;
}
.fas {
  align-self: center;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="col-md-4 mb-1 d-flex cutomsClass">
  <i class="fas fa-tree fa-4x"></i>
  <h4 class="my-4" font-weight-bold>The Park</h4>
  <p>Text</p>
</div>

Second way: if you want to center everything along with icon,

.cutomsClass  {
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: center;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" />
<div class="col-md-4 mb-1 d-flex cutomsClass">
  <i class="fas fa-tree fa-4x"></i>
  <h4 class="my-4" font-weight-bold>The Park</h4>
  <p>Text</p>
</div>
Atul Rajput
  • 4,073
  • 2
  • 12
  • 24