I'm creating marquee. These are the steps:
To do that I have to make a text-shadow
next to the original text. The problem is the text width is not constant so I can do something like:
...{
text-shadow: 619px 0 0 black;
}
这是我的代码:
.marquee {
white-space: nowrap;
overflow: hidden;
pointer-events: none;
text-shadow: 619px 0 0 black;
}
.marquee>* {
width: 100%;
display: inline-block;
transform: translateX(0%);
animation: marquee 5s linear infinite;
will-change: transform;
}
@keyframes marquee {
to {
transform: translateX(-100%);
}
}
<div class="marquee">
<h1>lorem ipsum dolor ist as ment lorem ipsum</h1>
</div>
注意:我知道我可以获得文本的宽度,并根据它在JavaScript中设置阴影.