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

相关推荐
sheji34167 小时前
【开题答辩全过程】以 基于微信小程序的社区养老积分银行系统的设计为例,包含答辩的问题和答案
微信小程序·小程序
她超甜i10 小时前
css省略号展示,兼容性强,js判断几行,不需要定位
javascript·css·vue.js
Mr Xu_11 小时前
深入分析Element UI Tree组件在本地与生产环境样式差异问题
css·ui·elementui
梦65011 小时前
CSS 元素垂直水平居中的 8 种方法
前端·css
前端 贾公子13 小时前
深入浅出 CSS 属性:pointer-events: none
前端·css
前端 贾公子17 小时前
npm 发包配置双重身份验证
前端·javascript·微信小程序·小程序·github
LBJ辉18 小时前
CSS - code
前端·css
独自归家的兔18 小时前
微信小程序开发框架全解析:成熟项目架构、主流技术与优劣对比
微信小程序·小程序
qq_3363139319 小时前
javaweb-HTML和CSS(2)
前端·css·html
_OP_CHEN19 小时前
【前端开发之CSS】(四)CSS 常用元素属性宝典(下):背景与圆角进阶指南,让页面颜值飙升!
前端·css·html·页面开发·gui开发·css元素属性