CSS实现自动滚屏,参照了各位前辈的文章

 直接使用CSS实现自动滚屏,上代码 :)

<html lang="en">
<head>
    <meta charset="UTF-8">
   <script>
        function Mychange(str){
        //  预留接口 

        str = document.getElementById("Toshow").value ;

        document.getElementById("shower").innerHTML = str; 
        
      }
  
    </script> 

    <title>纯css实现文字循环滚动效果及暂停</title>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }
 
        .box {
            width: 350px;
            height:300px;
            margin: 0 auto;
            border: 0px solid #ff6700;    
            background-color:black;     
            overflow: hidden;
        }
   
 
        .animate {
            padding-top: 50px;
            padding-left: 10px;
            font-size: 12px;
            color: #000;
            display: inline-block;
            white-space: nowrap;
            animation: 10s wordsLoop linear infinite normal;
        }
 
        @-webkit-keyframes wordsLoop {
            0% {
                transform: translateY(250px);
                -webkit-transform: translateY(250px);
            }
            100% {
                transform: translateY(-100%);
                -webkit-transform: translateY(-100%);
            }
        }

     .animate:hover{

      animation-play-state: paused;

     }
    </style>
</head>
<body>
<div class="box">
    <p class="animate" style="color:yellow;font-size:20px;">
      <img src="./flag.jpg"/>  
     <span id='shower'>
          秋天来了,春天还会远吗!
     </span>
    </p>
</div>
<div>
 <input name='Toshow' id='Toshow' οnclick="JavaScript:Mychange('ToShow')"/>
 
</div>
</body>
</html>

以上就可以实现自动滚屏的模块,可以嵌套到DIV中作为模块,增加亮色,也可扩展。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值