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

相关推荐
码云数智-大飞6 小时前
自助建站系统哪个好?快速建站哪个平台好
微信小程序
肖。354878709411 小时前
html中onclick误区,后续变量会更改怎么办?
android·java·javascript·css·html
用户57573033462411 小时前
🎨 CSS变量彻底指南:从入门到精通,99%的人不知道的动态样式魔法!
css
用户57573033462411 小时前
🎯 CSS 定位详解:从入门到面试通关
css
凯里欧文42711 小时前
🔥真正高级的前端,早就用这 10 个 CSS 特性干掉 80% 冗余代码
前端·css
大黄说说12 小时前
微信小程序制作平台有哪些?SaaS小程序搭建平台推荐
微信小程序
Never_Satisfied12 小时前
在HTML & CSS中,letter-spacing详解
前端·css·html
Never_Satisfied12 小时前
在HTML & CSS中,Animation 属性使用详解
前端·css·html
明月_清风13 小时前
告别视口依赖:Container Queries 开启响应式组件的“后媒体查询”时代
前端·css
明月_清风13 小时前
从样式表到渲染引擎:2026 年前端必须掌握的 CSS 架构新特性
前端·css