I will post a solution that I arrived here that I found interesting and solves some bugs.
The main thing here was to make a small Hake to the underline
cool rendering. For this I needed to use a transparent linear-gradient as span background. I don’t wonder why, because I discovered this accidentally... While I was testing the behavior of the animated element I put a background-color
on it and I realized that the bug stopped, but using the color in rgba()
the problem comes back, but with a background-imagem: linear-gradiend
the bug does not happen, at least in the Chrome!
I also had to use the property text-underline-position: under;
to fix this problem on Chrome:
See the result In Chrome and Firefox
I also needed to make an adjustment using display:inline-block,
overflow
and height
to control how the line will get cut off etc...
Follow the code used:
div {
font-family: sans-serif;
font-size: 2rem;
}
div span,
div .efeito{
display: inline-block;
height: 60px;
overflow: hidden;
}
div .efeito{
font-weight: bold;
text-decoration: underline;
text-decoration-color: orange;
text-underline-position: under;
position: relative;
}
div .efeito:hover{
text-decoration: none;
}
div .efeito::after{
content: attr(data-text);
width: 100%;
color: transparent;
position: absolute;
top: 0;
left: 15px;
transition: 0s linear;
text-decoration: none;
text-decoration-style: none;
text-decoration-color: orange;
display: inline-block;
height: 60px;
text-underline-position: under;
background-image: linear-gradient(rgba(0,0,0,0.0), rgba(0,0,0,0.0));
z-index: -1;
}
div .efeito:hover::after {
animation: underx 500ms infinite linear;
text-decoration: underline;
text-decoration-style: wavy;
text-decoration-color: orange;
}
@keyframes underx {
to {
left: 0px;
}
}
<div>
<span class="efeito" data-text="meuy texto 123">meuy texto 123</span> <span>segue conteúdo.</span>
</div>
OBS: In fonts of different sizes quite possibly you will need to adjust the values that are in PX
The question is how to leave excited (moving)?
– Costamilam
@Guilhermecostamilam this there, how to put this underline to run?
– hugocsl
@David thanks for editing
– hugocsl
@hugocsl where do you get this gif? there’s some link for me to take a look at?
– Renan
@Renanosorio, svg effect
– David
@Renanosorio is this link right there that David said, inclusive la tem MUITO coisa boa, da para perder uma tarde la fácil
– hugocsl