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

相关推荐
千寻技术帮5 小时前
50035_基于微信小程序的民宿管理系统
微信小程序·源码·ppt·源代码管理·项目文档·民宿
yqcoder9 小时前
在 scss 中,&>div 作用
前端·css·scss
小马哥编程9 小时前
这个variables.scss文件中$menuText:#bfcbd9;:export {menuText: $menuText; }的语法符合要求吗
前端·css·scss
爆浆麻花9 小时前
为什么有些人边框不用border属性
前端·css
计算机毕设定制辅导-无忧学长10 小时前
基于微信小程序的高校订餐小程序
微信小程序·小程序
www_stdio10 小时前
用 localStorage 打造本地待办清单:一个轻量级的前端实践
javascript·css·json
光影少年11 小时前
css影响性能及优化方案都有哪些
前端·css
stormsha13 小时前
CSS 样式美学从基础语法到界面精筑的实战宝典
前端·css·postcss·设计语言
yqcoder14 小时前
css 中,backdrop-filter: blur(10px) 作用
前端·css
從南走到北15 小时前
JAVA国际版同城跑腿源码快递代取帮买帮送同城服务源码支持Android+IOS+H5
android·java·ios·微信小程序