微信小程序无缝衔接弹幕效果纯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,很少看博客,对你有帮助别忘记点赞收藏。

相关推荐
什么时候星期五12 小时前
antd 4.x Tabs 点击阻止冒泡
css·react.js
八哥程序员12 小时前
从border-image 到 mask + filer 实现圆角渐变边框
前端·css
顾安r12 小时前
11.29 脚本游戏 单页面格斗游戏模板
前端·javascript·css·游戏·virtualenv
天蓝色的鱼鱼14 小时前
写Tailwind CSS像在写屎山?这锅该不该它背
前端·css
吹水一流14 小时前
微信小程序页面栈:从一个 Bug 讲到彻底搞懂
前端·微信小程序
Jing_Rainbow19 小时前
【 Weapp-3 /Lesson20(2025-11-04)】路虎卫士小程序开发详解:从架构到细节的深度解析🚙📱
微信·微信小程序·程序员
大怪v19 小时前
【创世界01】头脑热一把,我要带你纯前端手搓虚拟世界💪!
javascript·css·html
@大迁世界20 小时前
03.CSS嵌套 (Nesting)
前端·css
@大迁世界20 小时前
02.CSS变量 (Variables)
前端·css