微信小程序无缝衔接弹幕效果纯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 小时前
微信小程序黑马优购(项目)(二)
微信小程序·小程序
panda491911 小时前
css主流布局
前端·css
计算机徐师兄12 小时前
Java基于SpringBoot的足球队管理平台小程序【附源码、文档说明】
微信小程序·小程序·足球队管理平台小程序·java足球队管理平台小程序·足球队管理微信小程序·足球队管理平台·jav足球队管理小程序
合作小小程序员小小店12 小时前
web网页开发,在线%医院诊断管理%系统,基于Idea,html,css,jQuery,java,jsp,ssh,mysql。
java·前端·css·数据库·jdk·html·intellij-idea
软件技术NINI12 小时前
html css js网页制作成品——html+css+js5 页 jk制服附源码
javascript·css·html
重铸码农荣光15 小时前
从 0 到 1 实现 LocalStorage 待办清单:CSS 进阶 + 前端工程化思想实践
css·前端工程化
笨笨狗吞噬者17 小时前
【uniapp】小程序实现自由控制组件JSON文件配置
vue.js·微信小程序·vite
凌波粒19 小时前
CSS基础详解(1)
前端·css
千寻技术帮1 天前
50035_基于微信小程序的民宿管理系统
微信小程序·源码·ppt·源代码管理·项目文档·民宿
yqcoder1 天前
在 scss 中,&>div 作用
前端·css·scss