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

相关推荐
be or not to be6 小时前
深入理解 CSS 浮动布局(float)
前端·css
StarChainTech8 小时前
电动车租赁中的智能管理:电子围栏技术如何改变出行行业
大数据·人工智能·微信小程序·小程序·团队开发·软件需求·共享经济
南山安8 小时前
Tailwind CSS:顺风CSS
javascript·css·react.js
王小菲10 小时前
《网页布局速通:8 大主流方案 + 实战案例》-pink老师现代网页布局总结
css·面试·html
2503_9284115610 小时前
12.26 小程序问题和解决
前端·javascript·微信小程序·小程序
程序员刘禹锡11 小时前
浮动以及导航条和简单布局!!!(12.29日)
css·html·css3
GDAL11 小时前
从零开始上手 Tailwind CSS 教程
前端·css·tailwind
vim怎么退出13 小时前
一次线上样式问题复盘:当你钻进 CSS 牛角尖时,问题可能根本不在 CSS
前端·css
yyf1989052514 小时前
CSS相关中文书籍
css
qq_124987075315 小时前
基于springboot的智能任务管理助手小程序设计与实现(源码+论文+部署+安装)
spring boot·后端·信息可视化·微信小程序·小程序·毕业设计·计算机毕业设计