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

相关推荐
晴殇i18 小时前
CSS Grid 与 Flexbox:现代前端布局的双子星
前端·css
曹卫平dudu18 小时前
一起学习TailWind Css
前端·css
加油乐1 天前
css及js实现正反面翻转
前端·javascript·css
腾讯云云开发1 天前
【你可能不知道的开发技巧】一行代码完成小程序的CloudBase鉴权登录
前端·后端·微信小程序
踢球的打工仔1 天前
前端css(2)
前端·css
韩曙亮1 天前
【Web APIs】元素偏移量 offset 系列属性 ④ ( offset 属性案例 - 放大镜效果 )
前端·javascript·css·html·offset·dom·web apis
毕设源码-钟学长1 天前
【开题答辩全过程】以 基于微信小程序的汉服馆商城的设计与实现为例,包含答辩的问题和答案
微信小程序·小程序
计算机毕设指导61 天前
基于微信小程序的心理咨询预约系统【源码文末联系】
java·spring boot·mysql·微信小程序·小程序·tomcat·maven
相逢一笑与君行1 天前
css使用grid布局实现网格(表格),动态调整行高,列宽,整体缩放,插入行,列,删除行,列
前端·css·react