CSS 动画帧自动滚动

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>纯css实现文字循环滚动效果及暂停</title>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }
 
        .box {
            width: 150px;
            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: 5s 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;"> 
     <span id='shower'>
         从下向上滚动
     </span>
    </p>
</div>
</body>
</html>

2.从右往左

<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>纯css实现文字循环滚动</title>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }
        .box {
            width: 300px;
            height:30px;
            margin: 0 auto;
            border: 0px solid #ff6700;    
            background-color:black;     
            overflow: hidden;
        }
        .animate {

            padding-left: 10px;
            font-size: 12px;
            color: #000;
            display: inline-block;
            white-space: nowrap;
            animation: 5s wordsLoop linear infinite normal;
        }
 
        @-webkit-keyframes wordsLoop {
            0% {
                transform: translateX(250px);
                -webkit-transform: translateX(250px);
            }
            100% {
                transform: translateX(-100%);
                -webkit-transform: translateX(-100%);
            }
        }
     .animate:hover{
      animation-play-state: paused;
     }
    </style>
</head>
<body>
<div class="box">
    <p class="animate" style="color:yellow;font-size:20px;"> 
     <span id='shower'>
         从右往左滚动
     </span>
    </p>
</div>
</body>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值