单行文字滚动,单行文字轮播,文字轮播JS代码,一行代码实现文字轮播

<style>
div.screen {width: 100%;height: 40px;overflow: hidden;} a.textA {text-decoration: none;display: block;height: 40px;line-height: 40px;color: transparent;transition: all 2s} a.textA:first-child {margin-top: -40px;}a.textA:nth-child(2) {color: #000;}
</style>


 <div class="screen">
                <a class="textA" href="https://www.baidu.com">老和尚非要给小和尚讲故事 </a><!-- 第五句话 -->
                <a class="textA" href="http://www.baidu.com">从前有一座山,山上有一座庙 </a><!-- 第一句话 -->
                <a class="textA" href="http://www.baidu.com">庙里有一个老和尚和一个小和尚</a><!-- 第二句话 -->
                <a class="textA" href="http://www.baidu.com">老和尚在给小和尚讲故事 </a><!-- 第三句话 -->
                <a class="textA" href="http://www.baidu.com">小和尚不想听老和尚讲故事 </a><!-- 第四句话 -->
</div>
 <script>
                setInterval(function () { document.getElementsByClassName("screen")[0].appendChild(document.querySelector('.textA')); }, 2800);
            </script> 
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。