Warm tip: This article is reproduced from stackoverflow.com, please click
reactjs icons font-awesome

ReactJs overlay Font awesone Icons

发布于 2020-03-27 15:41:46

I want to ask how we can stack Font Awesome icons in ReactJS.

In HTML we use the following code:

<span class="fa-stack fa-2x">
  <i class="fas fa-circle fa-stack-2x"></i>
  <i class="fas fa-flag fa-stack-1x fa-inverse"></i>
</span>

And in ReactJS we use:

<FontAwesomeIcon icon={faFlag} />

How to stack a circle on user so that it looks as if Flag icon is in circle

Questioner
Abdullah Mufti
Viewed
31
Emanuele Scarabattoli 2020-01-31 16:49

Yo can do something like that and play with positioning and flex:

.the-wrapper {
  position: relative;
}

.the-wrapper .icon {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

</style>

<span class="fa-stack fa-2x the-wrapper">
  <FontAwesomeIcon icon={faCircle} />
  <div class="icon">
    <FontAwesomeIcon icon={faFlag} />
  </div>
</span>