0

I have a div element that contains two images. Using CSS :hover, I toggle the display of the two images (FontAwesome icons)

<div class="alternating-content-item-content alternating-content-item__content col-md-6">
  <div class="alternating-content-item-content__padding">
    <h3 class="alternating-content-item-content__heading">Trading</h3>
    <p class="alternating-content-item-content__blurb">Lorem ipsum dolor sit amet, consectetur adipiscing elit. </p>
    <a href="http://www.google.com" target="_blank" class="alternating-content-item-content__link">
      Read More
      <i class="fa fa-chevron-right fa-hover-hidden read-more-icon"></i>
      <i class="fa fa-arrow-right fa-hover-show read-more-icon"></i>
    </a>
  </div>
</div>

My CSS is

.fa.fa-hover-show {
    display: none;
}

&:hover {
    .fa.fa-hover-hidden {
        display: none;
    }

    .fa.fa-hover-show {
        display: inline-block;
    }
}

How can I add the transition/transformation to the div hover event to make a smooth animation between the two fa icons?

Styx
  • 9,863
  • 8
  • 43
  • 53
Mike
  • 2,391
  • 6
  • 33
  • 72

1 Answers1

0

If you want a smooth animation you should use opacity. For example:

button {
    transition: opacity 0.5s linear;
}

.fa.fa-hover-show {
    opacity: 0
}

button:hover {
    .fa.fa-hover-hidden {
        opacity: 0
    }

    .fa.fa-hover-show {
        opacity: 1
    }
}