<!DOCTYPE html>
<html>
<head>
<title>文本滚动</title>
<style>
@keyframes scroll {
0% {
transform: translateX(30px); /* 从哪里开始滚动 */
}
100% {
transform: translateX(-100%); /* 最终滚动到全部不见 */
}
}
.scrollText {
white-space: nowrap; /* 合并空白符,且阻止换行 */
width: max-content; /* 保证容器与文本同宽,滚动速度是width/滚动时间 */
animation: scroll 10s linear infinite; /* 设置滚动时间为10s */
}
.scrollText:hover {
animation-play-state: paused; /* 放鼠标停止滚动 */
}
</style>
</head>
<body>
<div class="scrollText">
你发如雪 凄美了离别 我焚香感动了谁 邀明月 让回忆皎洁 爱在月光下完美
</div>
</body>
</html>