我有一个 CSS + Javascripts 幻灯片,取自W3Schools 网站示例。
这是适合我的网络应用程序的代码(几乎相同):
$(document).ready(function() {
var slideIndex = 1;
function showSlides(n) {
var slides = $(".mySlides");
var i;
if (n > slides.length) {
slideIndex = 1;
}
if (n < 1) {
slideIndex = slides.length;
}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slides[slideIndex - 1].style.display = "block";
}
function plusSlides(n) {
showSlides(slideIndex += n);
}
showSlides(slideIndex);
$(".prev").click(function() {
plusSlides(-1);
});
$(".next").click(function() {
plusSlides(1);
});
});Run Code Online (Sandbox Code Playgroud)
@-webkit-keyframes fade …Run Code Online (Sandbox Code Playgroud)