我尝试了一些不同的东西但没有运气。我想让当前图像慢慢淡出并淡入下一张图像。
HTML
<div class="TestRotator " , style="text-align: center; padding-top: 20px; padding-bottom: 50px;">
<img
src="/Users/loh/Documents/app1/images/0.png"
,
height="130"
id="rotator"
,
class="img-fluid, rounded image-hover"
alt="Responsive image"
/>
</div>
<script src="js_src/imagechanger.js"></script>
JS
(function () {
var rotator = document.getElementById("rotator"); // change to match image ID
var imageDir =
"/Users/loh/Documents/app1/images/";
var delayInSeconds = 3;
var num = 0;
let currentIndex = 0;
const totalImages = 16;
const changeImage = function () {
var incre = Math.floor(Math.random() * (totalImages-1) ) + 1;
num += incre;
num = num % totalImages;
rotator.src = imageDir + num + ".png";
};
setInterval(changeImage, delayInSeconds * 1000);
})();
白猪掌柜的
天涯尽头无女友
相关分类