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

相关推荐
kyh10033811201 小时前
微信小游戏《找茬找汉字闯关王》源码赠送
microsoft·微信·微信小程序·微信小游戏·找茬小游戏·微信找茬消除
码云数智-园园2 小时前
小程序制作平台有哪些?2026微信小程序制作平台综合评测
微信小程序
陆枫Larry2 小时前
CSS 踩坑笔记:为什么列表底部的 margin-bottom 总是“失效”?
css
陆枫Larry2 小时前
深入浅出:CSS 中的“隐形结界”——BFC 详解
前端·css
码云数智-大飞3 小时前
小程序快速开发平台有哪些?微信小程序制作平台综合评测
微信小程序
coding随想4 小时前
深入Modernizr源码:揭秘CSS伪类检测的底层逻辑
前端·css
云游云记5 小时前
vue2 vue3 uniapp (微信小程序) v-model双向绑定
微信小程序·uni-app·vue
黑睿5 小时前
微信小程序,skyline引擎,display: grid失效问题解决
microsoft·微信小程序·小程序
程序员林北北5 小时前
【前端进阶之旅】50 道前端超难面试题(2026 最新版)|覆盖 HTML/CSS/JS/Vue/React/TS/ 工程化 / 网络 / 跨端
前端·javascript·css·vue.js·html
毕设源码-朱学姐20 小时前
【开题答辩全过程】以 基于微信小程序的大学生安全素质综合培养平台设计与实现为例,包含答辩的问题和答案
微信小程序·小程序