JSFiddle - React, Tailwind, and code Playground

by Léo Durand

HTML

<div class="box-info-busi">
  <div class="hover-ul"></div>
  <a href="mailto:[email protected]" onmouseover="textWidth(this)" onmouseout="textWidthInitial(this)">
     [email protected]</a>
     
 <div class="hover-ul"></div>
  <a href="www.studio-dot.fr" onmouseover="textWidth(this)" onmouseout="textWidthInitial(this)">www.studio-dot.fr</a>
</div>

CSS

body {
  margin: 0;
  padding: 0;
}

.box-info-busi {
  width: 200px;
  bottom: 100px;
  position: absolute;
}

.box-info-busi a {
  font-family: Maax;
  font-size: 10pt;
  color: black;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin-top: 1vh;
  padding-left: 15px;
  text-decoration: none;
  display: inline-block;
}

.hover-ul {
  background: linear-gradient(90deg, #009edf 0%, #2af598 100%);
  width: 10px;
  height: 1px;
  top: 10px;
  transition: 0.3s ease;
  position:relative;
}

JavaScript

function textWidth(el) {

  var i;
  for (i = 0; i < el.innerHTML.length; i++) {
    el.previousSibling.previousElementSibling.style.width = el.clientWidth + 15 + 'px';
    el.previousSibling.previousElementSibling.style.background = 'linear-gradient(90deg, #009edf 0%, #2af598 100%)';
  }

}

function textWidthInitial() {
  var underlineDiv = document.getElementsByClassName("hover-ul");
  var i;
  for (i = 0; i < underlineDiv.length; i++) {
    var txtWidth = (underlineDiv[i].clientWidth + 1);
    underlineDiv[i].style.width = '10px';
    underlineDiv[i].style.transition = "all 0.5s";

  }
}