如何用JavaScript编写公告栏自动上下滚动的代码?
- 内容介绍
- 文章标签
- 相关推荐
本文共计462个文字,预计阅读时间需要2分钟。
公告栏上下滚动效果 body { background-color: #f0f0f0; } .scroll-container { width: 300px; height: 100px; overflow: hidden; position: relative; } .scroll-content { position: absolute; width: 300px; animation: scroll-up 10s linear infinite; } @keyframes scroll-up { 0% { transform: translateY(0); } 100% { transform: translateY(-100%); } } 本文本家分享了JS公告栏上下滚动效果的实现代码,供大家参考学习。
本文共计462个文字,预计阅读时间需要2分钟。
公告栏上下滚动效果 body { background-color: #f0f0f0; } .scroll-container { width: 300px; height: 100px; overflow: hidden; position: relative; } .scroll-content { position: absolute; width: 300px; animation: scroll-up 10s linear infinite; } @keyframes scroll-up { 0% { transform: translateY(0); } 100% { transform: translateY(-100%); } } 本文本家分享了JS公告栏上下滚动效果的实现代码,供大家参考学习。

