html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Marquee</title>
<style>
.marquee {
margin-left: 100px;
width: 300px;
white-space: nowrap;
overflow: hidden;
border: 1px solid #4c7cee;
}
.marquee-txt {
display: inline-block;
padding-left: 100%; /* 从右至左开始滚动 */
animation: marqueeAnimation 4s linear infinite;
}
@keyframes marqueeAnimation {
0% {
transform: translate(0, 0);
}
100% {
transform: translate(-100%, 0);
}
}
</style>
</head>
<body>
<div class="marquee">
<span class="marquee-txt">css实现跑马灯(电子屏滚动)效果</span>
</div>
</body>
</html>