My typing animation changes position everytime the text length , how can i make it stay at one place and just do animation
When ever the text to be typed by animtion get smaller it moves to center right and to left when text is in more.
video https://streamable.com/62jzwg
css
.hometxt {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
gap: 1.4rem;
height: 50vh;
}
div.hometxt span{
position: relative;
}
.hometxt span::before{
content: "FrontEnd Developer";
font-size: 2.25rem;
font-weight: 500;
animation: text 20s infinite;
}
.hometxt span::after {
content: '';
position: absolute;
height: 3rem;
width: calc(100% + 0.8rem);
background-color:white;
border-left: 2px solid black;
animation: cursor 0.8s infinite, typing 20s steps(14) infinite;
right: -0.5rem;
}
@keyframes cursor {
To{
border-left: 2px solid transparent;
}
}
@keyframes text {
0%,20%{
content: "FrontEnd Developer";
}
21%,40%{
content: "PHP Developer";
}
41%,60%{
content: "React/Next Developer";
}
61%,80%{
content: "Web Designer";
}
81%,100%{
content: "Freelancer";
}
}
@keyframes typing {
10%,15%,30%,35%,50%,55%,70%,75%,90%,95%{
width: 0;
}
5%,20%,25%,40%,45%,60%,65%,80%,85%{
width: calc(100% + 0.8rem);
}
}
<div class="hometxt">
<h1>Hi, I am</h1>
<p>Reyyan Yaqub</p>
<span></span>
</div>
I tried adding min eidth but didnt work
2
Answers
Because the span is centered so it doesn’t have constant width that’s why cursor appears at different location.
Solution would be wrap the
.hometxt
in a container and apply certain width then every thing will be left alignedDo you want to something like this: