我注意到我一直在开发的一个新网站有一些奇怪的行为。本质上,我有一个登录页面,它有一个大横幅图像作为背景,使用 Jquery 每五秒淡入其他图像。在计算机上,淡入淡出序列效果很好,但在移动设备(iphone、ipad 等)上查看时,图像永远不会出现。我最初认为这与查看设备的屏幕尺寸有关(这导致图像不显示在 iPhone 上)......但是,这个问题似乎也发生在 ipad 上,所以我不确定屏幕分辨率是否真的是问题所在。
我使用的代码是对在线教程的轻微修改。基本上,这里是html代码:
<div id="slideshow">
<img class="active" src="image1.jpg" alt="Slideshow Image 1" />
<img src="image2.jpg" alt="Slideshow Image 2" />
<img src="image3.jpg" alt="Slideshow Image 3" />
<img src="image4.jpg" alt="Slideshow Image 4" />
<img src="image5.jpg" alt="Slideshow Image 5" />
</div>
Jquery 代码如下所示:
<script type="text/javascript">
function slideSwitch() {
var $active = $('#slideshow IMG.active');
if ( $active.length == 0 ) $active = $('#slideshow IMG:last');
// use this to pull the images in the order they appear in the markup
var $next = $active.next().length ? $active.next()
: $('#slideshow IMG:first');
// uncomment the 3 lines below to pull the images in random order
// var $sibs = $active.siblings();
// var rndNum = Math.floor(Math.random() * $sibs.length );
// var $next = $( $sibs[ rndNum ] );
$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 );
});
</script>
还有一些 CSS 代码,但我不完全确定这会导致问题。尽管如此:
#slideshow_content {
top: 50%;
position: fixed;
}
#slideshow {
position: absolute;
z-index: -1;
}
#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;
}
#slideshow img {
max-width: 100%;
height: auto;
width: auto;
position: fixed;
top: 50%;
left: 0;
}
此外,可以在以下网址找到我正在处理的存在此问题的网站的链接:www.liftarchitects.com