小程序实现弹幕功能-无限循环,不会重叠

以下是支付宝小程序代码,先上效果图

在这里插入图片描述
以下是axml代码:

<view class="view">
  <block a:for="{
   {bulletChatData}}" a:key="id">
    <text class="item"  style="animation: first 8s linear forwards;top:{
   {item.top}}%;color:{
   {item.color}};">{
   {
   index+item.text}}</text>
  </block>
</view>

js:


const app = getApp();
var bulletChatList = [];
var id = 0;
var cycle = null;  //计时器
var topArray = [0, 15, 30, 45, 60, 75, 90, 105, 120, 135, 150];//用来做随机top值
var usedTop = [];
  • 7
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 7
    评论
实现HTML图片重叠变换,可以使用CSS中的`z-index`属性和`position`属性来控制图片的层叠顺序和位置。具体实现过程如下: 1. 将所有图片的`position`属性设置为`absolute`,这样图片就可以脱离文档流,方便控制位置和层叠顺序。 2. 将所有图片的`z-index`属性设置为相同的值,这样它们就处于同一层级,可以让它们互相重叠。 3. 给每个图片设置不同的`left`或`right`值,来使它们的位置不同。 4. 使用CSS3的`transition`属性和`transform`属性来实现图片的变换效果,比如旋转、平移等。 实现无缝无限循环展示效果,可以采用CSS3的`animation`属性,通过不断地改变图片的位置和透明度,来实现循环展示的效果。具体实现过程如下: 1. 定义一个`@keyframes`规则,用来描述图片的动画效果。在这个规则中,可以定义图片的位置、透明度等属性,以及动画的持续时间、延迟时间、重复次数等参数。 2. 将图片的`animation`属性设置为定义好的`@keyframes`规则,可以控制图片的动画效果。 3. 为了实现无限循环展示,需要将多个图片按照一定的顺序排列,并且让它们不断地重复播放动画。 下面是一个HTML图片重叠变换和CSS无限循环展示效果的示例代码: ```html <!DOCTYPE html> <html> <head> <title>HTML图片重叠变换和CSS无限循环展示效果</title> <style type="text/css"> .container { position: relative; width: 500px; height: 500px; margin: 0 auto; overflow: hidden; } .container img { position: absolute; top: 0; left: 0; z-index: 1; transition: all 1s ease-in-out; transform-origin: center center; } .container img:nth-child(2) { left: 100px; z-index: 2; transform: rotate(45deg); } .container img:nth-child(3) { left: 200px; z-index: 3; transform: rotate(90deg); } .container img:nth-child(4) { left: 300px; z-index: 4; transform: rotate(135deg); } .container img:nth-child(5) { left: 400px; z-index: 5; transform: rotate(180deg); } .container:hover img { transform: rotate(360deg); } .animation-container { position: relative; width: 500px; height: 500px; margin: 0 auto; overflow: hidden; } .animation-container img { position: absolute; top: 0; left: 0; animation: slide 10s linear infinite; } .animation-container img:nth-child(2) { left: 100%; animation-delay: -8s; } .animation-container img:nth-child(3) { left: 200%; animation-delay: -6s; } .animation-container img:nth-child(4) { left: 300%; animation-delay: -4s; } .animation-container img:nth-child(5) { left: 400%; animation-delay: -2s; } @keyframes slide { 0% { transform: translateX(0%); opacity: 1; } 25% { transform: translateX(-100%); opacity: 0.5; } 50% { transform: translateX(-200%); opacity: 0.2; } 75% { transform: translateX(-300%); opacity: 0.5; } 100% { transform: translateX(-400%); opacity: 1; } } </style> </head> <body> <h2>HTML图片重叠变换</h2> <div class="container"> <img src="image1.jpg"> <img src="image2.jpg"> <img src="image3.jpg"> <img src="image4.jpg"> <img src="image5.jpg"> </div> <h2>CSS无限循环展示效果</h2> <div class="animation-container"> <img src="image1.jpg"> <img src="image2.jpg"> <img src="image3.jpg"> <img src="image4.jpg"> <img src="image5.jpg"> </div> </body> </html> ``` 在这个示例代码中,`.container`类表示HTML图片重叠变换的容器,`.animation-container`类表示CSS无限循环展示效果的容器。其中,`.container`类和`.animation-container`类的样式设置有些不同。 在`.container`类中,将所有图片的`position`属性设置为`absolute`,并设置它们的`left`值,使它们呈现出重叠效果。同时,给所有图片设置过渡效果和旋转效果,当鼠标悬停时可以触发旋转效果。 在`.animation-container`类中,将所有图片的`position`属性设置为`absolute`,并设置它们的`left`值,使它们呈现出水平排列的效果。同时,通过`animation`属性将所有图片绑定到同一个动画,不断地播放循环动画。其中,`.animation-container img:nth-child(n)`选择器可以用来为每个图片设置不同的延迟时间,实现无限循环展示的效果。 通过这个示例代码,可以了解到如何使用HTML和CSS实现图片重叠变换和无限循环展示效果
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值