Is it possible to achieve the following using only CSS without any JavaScript?
The desired outcome is a div containing two font awesome icons aligned to the right side.
Specifically, I am looking for:
- Icon of a pen that reacts on mouse hover
- Icon of an X that also reacts on mouse hover
I attempted to accomplish this by utilizing transforms and transitioning from display: none to display: block. However, it seems like animating this CSS property is not achievable. My current code snippet is as follows:
section.container {min-width: 500px; margin: 10% auto; text-align: center;}
.text-on-hover {cursor: pointer; font-size:20px;}
.text-on-hover:hover:before {opacity: 1;}
.text-on-hover:before {
content: attr(data-hover);
margin: 0 10px;
opacity: 0;
transition: all .5s ease-in-out;
}
<section class="container">
<i class="text-on-hover" data-hover="A long text">A</i>
<i class="text-on-hover" data-hover="Another long text">B</i>
</section>
Is there a way to achieve this effect using pure CSS? If not, what are the limitations preventing it?