0

この場所を使用してスライドショーを作成しましたが、CSS の特定の制限により、box-shadow プロパティを IMG に設定することはできません。

ただし、問題はスクリプトの性質によるもので、IMG の実行が完了すると、div に遭遇します。

div は装飾にのみ使用されるため、スクリプトは div に遭遇することは想定されていません (これも、box-shadow は IMG に使用できないためです)。#slideshadow div を無視するように、誰かがコードのフォーマットを手伝ってくれることを望んでいました。

HTML (CSS のおかげで置換写真で編集、寸法が必要でした):

<div id="slideshow">
  <img class="active" src="http://i.imgur.com/pPPkQDZ.jpg" alt="" />
  <img src="http://i.imgur.com/Axp8aGT.jpg" alt="" />
  <img src="http://i.imgur.com/UMpQ9eh.jpg" alt="" />
<div id="slideshadow">&nbsp;</div>
</div>

CSS:

#slideshadow {
    position: absolute;
    height:455px;
    width: 750px;
    box-shadow: inset 0px 0px 80px 0px rgba(0,0,0,0.75);
    border-top-left-radius: 25px;
    border-bottom-left-radius: 25px;
    border-left: 5px groove #990000;
    z-index: 15;
}

#slideshow {
    position:relative;
    height:455px;
    width: 750px;
    float: left;
}

#slideshow IMG {
    position:absolute;
    top:0;
    left:0;
    z-index:8;
    opacity:0.0;
    border-top-left-radius: 25px;
    border-bottom-left-radius: 25px;
    border-left: 5px groove #990000;
}

#slideshow IMG.active {
    z-index:10;
    opacity:1.0;
}

#slideshow IMG.last-active {
    z-index:9;
}

脚本:

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, 3000 );
});
4

1 に答える 1

0

内に特定の要素を渡すことができます.next()

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow IMG:last');

    var $next = $active.next('img').length ? $active.next('img'): $('#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, 3000 );
});
于 2015-04-13T13:39:33.843 に答える