The examples in this article are all written in small programs, but this does not affect the functions to be implemented. wxml Make one more copy of the box containing the picture so that the beginning and end of the looped picture are connected <view class="scrollbox dis-flex"> <view class="imgItem dis-flex" style="animation: {{computedAni}};"> <image src="../img/{{index + 1}}.jpg" wx:for="{{images}}" mode="aspectFill" wx:key="index"></image> </view> <view class="imgItem dis-flex" style="animation: {{computedAni}};"> <image src="../img/{{index + 1}}.jpg" wx:for="{{images}}" mode="aspectFill" wx:key="index"></image> </view> </view> wxss .dis-flex { display: flex; display: -webkit-flex; } .scrollbox { margin: 30px; text-align: center; border: 1px solid blue; height: 220rpx; align-items: center; overflow: hidden; } .imgItem { animation: 24s rowup linear infinite normal; } .imgItem image { width: 200rpx; height: 200rpx; margin: 0 20rpx; } @keyframes rowup { 0% { -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); } 100% { -webkit-transform: translate3d(-100%, 0, 0); transform: translate3d(-100%, 0, 0); } } @-webkit-keyframes rowup { 0% { -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); } 100% { -webkit-transform: translate3d(-1000px, 0, 0); transform: translate3d(-1000px, 0, 0); } } js The key to adjusting the speed is that the animation time is dynamically controlled by the number of looped items. Page({ data: { images: new Array(4), computedAni: '' }, onLoad: function () { this.setAniSpeed(this.data.images.length) }, setAniSpeed(num) { let time = Math.ceil(num / 5 * 15) // Here, the animation time is 15s when there are 5 pictures. You can adjust it yourself this.setData({ computedAni: `${time}s rowup linear infinite normal` }) } }) Click here to view the code snippet https://developers.weixin.qq.com/s/4gGngEm67Zlh This concludes this article about the sample code for implementing horizontal infinite scrolling with pure CSS3. For more relevant CSS3 horizontal infinite scrolling content, please search for previous articles on 123WORDPRESS.COM or continue to browse the related articles below. I hope you will support 123WORDPRESS.COM in the future! |
<<: Double loading issue when the page contains img src
>>: How to use the href attribute of the HTML a tag to specify relative and absolute paths
Container auto-start Docker provides a restart po...
Table of contents 1. Download 2. Installation and...
Table of contents Pull the image Run the image (g...
1. Multiple borders[1] Background: box-shadow, ou...
1. Introduction The difference between row locks ...
Achieve resultsImplementation Code html <heade...
Disadvantages of single-node database Large-scale...
Introduction to the usage of MySQL keyword Distin...
This article example shares the specific code of ...
This article shares the specific code for impleme...
If the server data is not encrypted and authentic...
Get the current time: select current_timestamp; O...
Table of contents 1. Introduction to docker-maven...
1. Install JDK Check the computer's operating...
For many domestic advertisers, the creation and ev...