感谢您的帮助
var slides = Array.from(document.querySelectorAll(".slide_element"));
var i = 0;
function test(){
if(i === slides.length - 1){
slides[slides.length - 1].classList.remove("displaying");
i = 0;
slides[i].classList.add("displaying");
}
else{
slides[i].classList.remove("displaying");
slides[i+1].classList.add("displaying");
i++;
}
}
setInterval(() => {
test();
}, 3000);
答案 0 :(得分:0)
在“ slide_element”中,删除display: none;
并添加过渡(全部),这样它将变成transition: all .3s;
并将其设置为绝对定位,这样您的css将如下所示:
.slide_element{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0;
transition: all 0.3s;
transform: translateX(1000px);
}