[英]Javascript/CSS slideshow: Using transparencies highlights flaws I don't know how to fix
我很想尽可能广泛地帮助将来的编码人员,这是一个相当具体的问题。
正如您在jsfiddle中所看到的,此幻灯片似乎对带有透明胶片的图片有问题。 有了透明胶片,转换就会变得很麻烦。 如果可能的话,我希望随着新图片的淡入而使旧图片淡出。
还有一个注意事项:slideshadow div的存在是有原因的,主要用于框阴影的使用,可以更好地控制z-index。
HTML:
<div id="slideshow">
<img class="active" src="http://i.imgur.com/tqMy9wn.png" alt="" />
<img src="http://i.imgur.com/vNyEFB0.png" alt="" />
<div id="slideshadow"> </div>
</div>
CSS:
#slideshow {
position:relative;
float:left;
height:245px;
width:200px;
}
#slideshow IMG {
position:absolute;
top:0;
left:0;
z-index:8;
opacity:0.0;
}
#slideshow IMG.active {
z-index:10;
opacity:1.0;
}
#slideshow IMG.last-active {
z-index:9;
}
#slideshadow {
position:absolute;
height:245px;
width:200px;
box-shadow:inset 0px 0px 80px 0px rgba(0,0,0,0.75);
z-index:15;
}
JS:
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
}, 2000, function () {
$active.removeClass('active last-active');
});
}
$(function () {
setInterval(slideSwitch, 7000);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.