CSS3实现图片自动上下轮播

 <div className = 'scrollContainer'>
       <div className = 'scrollWrap'>
           <div className = 'scrollRow'><img /></div>
           <div className = 'scrollRow'><img /></div>
           <div className = 'scrollRow'><img /></div>
        </div>
 </div>
.scrollContainer {
              width: 80%;
              display: flex;
              align-items: center;
              background: rgba(255, 245, 245, 1);
              border-radius: 8px;
              border: 1px solid red;
              filter: blur(0px);
              margin-bottom: 12px;
              padding: 16px;
              font-size: 16px;
              font-weight: 400;

              .scrollWrap {
                height: 22px;
                overflow: hidden;
                position: relative;
                flex: 1;

                .scrollRow {
                  position: absolute;
                  height: 100%;
                  width: 100%;
                }
              }

              @keyframes anim1 {
                0% {
                  top: 0;
                  opacity: 1;
                }

                45% {
                  top: 0;
                  opacity: 1;
                }

                50% {
                  top: -100%;
                  opacity: 0;
                }

                51% {
                  top: 100%;
                  opacity: 0;
                }

                95% {
                  top: 100%;
                  opacity: 1;
                }

                96% {
                  opacity: 1;
                }

                100% {
                  top: 0;
                  opacity: 1;
                }
              }

              @keyframes anim2 {
                0% {
                  top: 100%;
                  opacity: 0;
                }

                45% {
                  top: 100%;
                  opacity: 0;
                }

                50% {
                  top: 0;
                  opacity: 1;
                }

                95% {
                  top: 0;
                  opacity: 1;
                }

                100% {
                  top: -100%;
                  opacity: 0;
                }
              }

              .scrollRow:nth-child(1) {
                animation: anim1 5s linear infinite;
              }

              .scrollRow:nth-child(2) {
                top: 25px;
                animation: anim2 5s linear infinite;
              }
            }
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值