Transitional underscores for multiple lines of text

Recently, I noticed that text-decoration: underlineyou can not animate (go over). After a little research, I found that the best and most common solution is to use border-bottom. But, as you will see in this code fragment below, border-bottomnot the best solution in this case.

#borderText {
 border-bottom: 1px solid white; 
 transition: .5s;
}

#borderText:hover {
  border-bottom: 1px solid black;
}

#textDecor {
  text-decoration: none;
  transition: .5s;
  }

#textDecor:hover {
  text-decoration: underline;
  }
<p id="borderText">
  Lorem Ipsum Sit Amet<br />
  Some other Text<br />
  Some Other Text<br />
</p>

<p id="textDecor">
  Here is some text<br />
  with text-decoration and<br />
  as you should see, the text<br />
  is underlined but cannot be transitioned<br />
</p>
Run codeHide result

For clarification, I will explain the problem and purpose:

Problem: . How can you convert text with multiple lines of text?

Purpose: To effectively solve the problem above, and hopefully without any hacks.

, , , SIMPLE , , span.

+4
1

#borderText {
 border-bottom: 1px solid white; 
 transition: .5s;
 display: inline;
cursor: pointer;
}

#borderText:hover {
  border-bottom: 1px solid black;
}

#textDecor {
  text-decoration: none;
  transition: .5s;
  }

#textDecor:hover {
  text-decoration: underline;
  }
<p id="borderText">
  Lorem Ipsum Sit Amet<br />
  Some other Text<br />
  Some Other Text<br />
</p>

<p id="textDecor">
  Here is some text<br />
  with text-decoration and<br />
  as you should see, the text<br />
  is underlined but cannot be transitioned<br />
</p>
Hide result

#borderText {
 border-bottom: 1px solid white; 
 transition: .5s;
}

#borderText:hover {
  border-bottom: 1px solid black;
}

#textDecor {
  text-decoration: none;
  transition: .5s;
  }

#textDecor:hover {
  text-decoration: underline;
  }
<p id="borderText">
  Lorem Ipsum Sit Amet<br />
  Some other Text<br />
  Some Other Text<br />
</p>

<p id="textDecor">
  Here is some text<br />
  with text-decoration and<br />
  as you should see, the text<br />
  is underlined but cannot be transitioned<br />
</p>
Hide result

#borderText {
 border-bottom: 1px solid white; 
 transition: .5s;
}

#borderText:hover {
  border-bottom: 1px solid black;
}

#textDecor {
  text-decoration: none;
  transition: .5s;
  }

#textDecor:hover {
  text-decoration: underline;
  }
<p id="borderText">
  Lorem Ipsum Sit Amet<br />
  Some other Text<br />
  Some Other Text<br />
</p>

<p id="textDecor">
  Here is some text<br />
  with text-decoration and<br />
  as you should see, the text<br />
  is underlined but cannot be transitioned<br />
</p>
Hide result

#borderText {
 border-bottom: 1px solid white; 
 transition: .5s;
}

#borderText:hover {
  border-bottom: 1px solid black;
}

#textDecor {
  text-decoration: none;
  transition: .5s;
  }

#textDecor:hover {
  text-decoration: underline;
  }
<p id="borderText">
  Lorem Ipsum Sit Amet<br />
  Some other Text<br />
  Some Other Text<br />
</p>

<p id="textDecor">
  Here is some text<br />
  with text-decoration and<br />
  as you should see, the text<br />
  is underlined but cannot be transitioned<br />
</p>
Hide result
+3

Source: https://habr.com/ru/post/1628939/


All Articles