Jquery图像滑块不适用于移动设备

时间:2013-09-26 16:41:15

标签: jquery

我一直在注意到我一直在努力的新网站的一些奇怪行为。基本上,我有一个登陆页面,它有一个大的横幅图像作为背景,使用Jquery每隔五秒就会淡入其他图像。在计算机上,淡入淡出的序列非常出色,但在移动设备(iphone,ipad等)上查看图像时,图像永远不会出现。我原本以为它与观看设备的屏幕尺寸有关(导致图像无法显示在iphone上)......但是,这个问题似乎也发生在ipad上,所以我是不确定屏幕分辨率是否真的是问题。

我正在使用的代码是online tutorial的略微修改。基本上,这是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

0 个答案:

没有答案