I'm working on this website and as you can see I'm making a typing effect on the last line of the last <p>
on the page. The only problem is that my website is somewhat responsive and the <article>
containing the last <p>
changes width, enough to change the words on the last line.
Right now, my effect is working with a <span>
preceded by a <br />
but it looks weird if you got a large monitor.
I wondered if there was a way to select the last line with JavaScript and apply the span to the automatic last words happening after the last line automatic break.
It needs to be in JavaScript, I do not want to load jQuery for such a small website.
Here is the actual code of the last <p>
in case some of you dont want to open the link:
p{width:50%;text-align:right;}
span#typing {
width: 377.96875px;
white-space: nowrap;
overflow: hidden;
display: inline-block;
-webkit-animation: type 5s steps(70, end);
animation: type 5s steps(70, end);
}
@keyframes type{
from { width: 0; }
}
@-webkit-keyframes type{
from { width: 0; }
}
<p>
Jack Ü a également joué au Ultra Music Festival en 2015 avec l'ensemble du "Jack Ü crew", avec contributions en direct
<br />
<span id="typing">
de
<a target="_blank" href="https://en.wikipedia.org/wiki/CL_(singer)">CL</a>,
<a target="_blank" href="https://en.wikipedia.org/wiki/Kai_(Alessia_De_Gasperis_Brigante)">Kai</a>,
<a target="_blank" href="https://en.wikipedia.org/wiki/Sean_Combs">Diddy</a>,
<a target="_blank" href="https://en.wikipedia.org/wiki/Kiesza">Kiesza</a>,
et
<a target="_blank" href="https://en.wikipedia.org/wiki/Justin_Bieber">Justin Bieber</a>.
</span>
<span class="blink"></span>
</p>