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

相关推荐
御形封灵36 分钟前
纯CSS实现方块下落等待动画
前端·css
转角羊儿38 分钟前
CSS补充重要知识
前端·css
林九生2 小时前
【Vue3】解决 Tailwind CSS v4 + Vite 8 中 `@import “tailwindcss“` 不起作用的问题
前端·css
奶糖 肥晨2 小时前
微信小程序定位功能开发实战:实现自动定位、城市切换与地图导航
微信小程序·小程序
笨笨狗吞噬者2 小时前
【uniapp】小程序支持分包引用分包 node_modules 依赖产物打包到分包中
前端·微信小程序·uni-app
遗憾随她而去.3 小时前
高德地图自定义点标记: SVG vs HTML+CSS两种方案
前端·css
啪叽4 小时前
别再手写 if-else 选字体颜色了,CSS contrast-color() 来帮你处理
前端·css
Irene19915 小时前
CSS中层叠上下文的定义与触发条件
css·z-index·层叠上下文
kyriewen117 小时前
Sass:让 CSS 从手工作坊迈入工业时代
前端·javascript·css·html·css3·sass·html5
用户69371750013847 小时前
微信悄悄搞大事!原生智能助手秘密研发,2026年改变亿人使用习惯
android·后端·微信小程序