使用marquee标签即可实现动态效果;
但是marquee被废弃了,这里就不推荐继续使用了
使用动画实现
<!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>Document</title>
<style>
.bar {
width: 520px;
overflow: hidden;
}
@keyframes text-scroll {
0% {
transform: translateX(520px);
}
100% {
transform: translateX(-100%);
}
}
.bar p {
white-space: nowrap;
animation: text-scroll linear infinite 10s;
}
</style>
</head>
<body>
<div class="bar">
<p>...</p>
</div>
</body>
</html>