jQuery 幻灯片放映帮助:为框阴影效果添加 div jQuery 选择 div
jQuery help for slideshow: adding a div for box-shadow effects has jQuery selecting the div
所以我用this place帮我创建了一个幻灯片,但是,由于CSS的某些限制,你不能给IMG设置box-shadow 属性。
但是,问题是由于脚本的性质,一旦通过 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"> </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 );
});
您可以在 .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 );
});
所以我用this place帮我创建了一个幻灯片,但是,由于CSS的某些限制,你不能给IMG设置box-shadow 属性。
但是,问题是由于脚本的性质,一旦通过 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"> </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 );
});
您可以在 .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 );
});