4
I’m making an animation with CSS but the effect is correct only in the first word of the text and the rest not. Would anyone know why this occurs?
h3{
position: absolute;
font-family: consolas;
letter-spacing: 5px;
color: transparent;
}
h3:before{
content: attr(data-text);
position: absolute;
overflow: hidden;
border-right: solid 1px #000;
width: 100%;
height: 100%;
animation: type 10s steps(27) infinite;
color: #000;
}
@keyframes type{
0%{
width: 0;
}
50%{
width: 100%;
}
100%{
width: 0;
}
}
<h3 data-text="Efeito CSS - Escrever Texto">
Efeito CSS - Escrever Texto
</h3>
Because, probably, as you are changing the width of the element, the text breaks into several lines, only appearing the text on the same line when the element has sufficient width for this.
– Woss
@Andersoncarloswoss What I’m finding strange is that the first word gets the right effect!
– LeAndrade
Because the browser breaks the word in half if the element is smaller than the word. Try working with the property
word-wrap
.– Woss