微信小程序无缝衔接弹幕效果纯CSS

效果图

主要运用蒙层、动画延迟

.wxml

复制代码
<view wx:for="{{detail}}" wx:key="{{index}}" class="container" style="--s:{{item.s}}s" >
  <view wx:for="{{2}}" wx:key="{{index}}" class="container-item">
    <text>HTML</text>
    <text>CSS</text>
    <text>JAVASCRIPT</text>
    <text>PHP</text>
    <text>JAVA</text>
    <text>VUE</text>
    <text>REACT</text>
  </view>
</view>

.js

复制代码
Page({
  data: {
    detail:[{s:10},{s:14},{s:4},{s:18},{s:6}],
  },
})

.wxss

复制代码
page{
  padding-top: 100rpx;
  background: #000;
}
.container{
  position: relative;
  display: flex;
  width:100%;
  overflow: hidden;
  -webkit-mask-box-image: linear-gradient(90deg,transparent,#fff,#fff,transparent);
  margin: 30rpx 0;
}
.container-item{
  white-space: nowrap;
}
.container-item text{
  display: inline-flex;
  margin: 20rpx;
  padding: 10rpx 20rpx;
  color: #fff;
  letter-spacing: 4rpx;
  background: #333;
  border-radius: 10rpx;
}
.container .container-item:nth-child(1){
  animation: animation var(--s) linear infinite;
}
.container .container-item:nth-child(2){
  animation: animation2 var(--s) linear infinite;
  animation-delay: calc(var(--s) / 2);
}
@keyframes animation {
  from{
    transform: translate(100%);
  }
  to{
    transform: translate(-100%);
  }
}
@keyframes animation2 {
  from{
    transform: translate(0);
  }
  to{
    transform: translate(-200%);
  }
}

遇到问题可以看我主页加我Q,很少看博客,对你有帮助别忘记点赞收藏。

相关推荐
Lucky小黄人5 小时前
微信小程序查看备案号
微信小程序·小程序
CappuccinoRose8 小时前
CSS 语法学习文档(十七)
前端·css·学习·布局·houdini·瀑布流布局·csspaintingapi
码云数智-园园8 小时前
小程序制作平台哪个好?微信小程序制作平台对比评测
微信小程序
keyborad pianist8 小时前
Web开发 Day1
开发语言·前端·css·vue.js·前端框架
Never_Satisfied8 小时前
在HTML & CSS中,可能导致父元素无法根据子元素的尺寸自动调整大小的情况
前端·css·html
毕设源码-郭学长9 小时前
【开题答辩全过程】以 基于微信小程序的当当手办店铺为例,包含答辩的问题和答案
微信小程序·小程序
qq_24218863329 小时前
微信小程序新年首页源码
微信小程序·小程序
Never_Satisfied9 小时前
在HTML & CSS中,img标签固定宽度时,img和图片保持比例缩放
前端·css·html
凯里欧文42710 小时前
CSS Grid 案例
前端·css
狂龙骄子10 小时前
RuoYi-Vue字典标签CSS样式自定义指南
css·前端框架·ruoyi·数据字典·若依·字典标签·样式属性