JSFiddle - React, Tailwind, and code Playground
by imys
HTML
<div class="wrap">
<h1 class="content">写一些文字</h1>
</div>
CSS
.wrap {
position: relative;
width: 500px;
height: 300px;
background: #fff;
}
.content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
margin: 0;
color: #2fb791;
}
.content:before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #fff;
animation: 4s linear 1s move infinite;
}
@keyframes move {
0% {
transform: translateX(100%)
}
2% {
transform: translateX(0)
}
15% {
transform: translateX(0)
}
100% {
transform: translateX(100%);
}
}