图像幻灯片脚本

Image Slideshow Script

本文关键字:脚本 幻灯片 图像      更新时间:2023-09-26

我想将图像显示为幻灯片。我有一个链接和每个图像的标题。

当循环遍历图像时,我还希望图像链接和标题相应更改。

我该怎么做?

你可以这样写:http://jquery.malsup.com/cycle/

不能使用PHP制作幻灯片。你可以使用javascript制作幻灯片。

查看此链接:

http://jquery.malsup.com/cycle/

让我给你一个简单的jquery淡出幻灯片

HTML

<div id="slideshow">
    <img src="img/img1.jpg" alt="" class="active" />
    <img src="img/img2.jpg" alt="" />
    <img src="img/img3.jpg" alt="" />
</div>
CSS

#slideshow {
    position:relative;
    height:350px;
}
#slideshow IMG {
    position:absolute;
    top:0;
    left:0;
    z-index:8;
}
#slideshow IMG.active {
    z-index:10;
}
#slideshow IMG.last-active {
    z-index:9;
}
一些JQuery

function slideSwitch() {
    var $active = $('#slideshow IMG.active');
    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
    var $next =  $active.next().length ? $active.next()
        : $('#slideshow IMG:first');
    $active.addClass('last-active');
    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}
$(function() {
    setInterval( "slideSwitch()", 5000 );
});

哦!是的,不要忘记导入jquery库