I’m trying to animate text and change the color in the middle of the screen, like this
HTML
<div class="text-mask">
<div class="scrolling-text">MASKED TEXT</div>
</div>
CSS
body {
background-color: #000;
}
.text-mask {
font-size: 100px;
font-weight: bold;
background: linear-gradient(to right, orange 50%, white 50%);
background-clip: text;
color: transparent;
position: relative;
height: 120px;
}
.scrolling-text {
/* transform: translateX(10px); */
/* position: relative */
}
As soon as I apply the styling of .scrolling-text
the text is gone. The idea I had was to change the value of the transform in order to get the walking/animated text.
Is there a way I can achieve this?
2
Answers
It looks like you’re trying to achieve a cool animated text effect! To fix the disappearing text issue, you might want to check how
background-clip: text
andcolor: transparent
are applied. Also, ensure that the text stays within the visible area by managing overflow and positioning properly. Adding an animation totransform
should create the scrolling effect you’re aiming for. Would love to see the final result when you get it working!transform
andbackground-clip
should belong to the same element