【问题标题】:JQUERY Fade slideshow without white in betweenJQUERY 淡入淡出幻灯片,中间没有白色
【发布时间】:2015-07-02 22:33:41
【问题描述】:

我在这个 Wordpress 网站 www.2eenheid.de 上有一个幻灯片。我试图弄清楚如何使图像褪色,使其在图像之间褪色,而不是先褪色为白色背景色,然后再褪色为图像。任何线索在我的情况下如何做到这一点,见下文?

javascript:

    <script type="text/javascript">
        $(function () {
            var imgsrc = '';
            imgsrc = $('.pikachoose').css('background-image');

            $('ul.slideshow-menu').find('a').hover(function () {
                var newImg = $(this).attr('src');
                $('.pikachoose').stop().fadeOut('slow', function () {
                    $(this).css({
                        'background-image': 'url(' + newImg + ')'
                    }).fadeTo('fast', 1);
                });

            }, function () {
                $('.pikachoose').stop().fadeOut('slow', function () {
                    $(this).css({
                        'background-image': imgsrc
                    }).fadeTo('fast', 1);
                });
            });

        });
    </script>

HTML

<div id="slideshow-main">
  <ul class="slideshow-menu">
   <li class=""><a title="Support / Beheer" href="/supportenbeheer" src="http://www.2eenheid.de/wp-content/themes/2eenheid/images/slideshow/slideshow-4.jpg"><img src="http://www.2eenheid.de/wp-content/themes/2eenheid/images/slideshow/slideshow-4.jpg" alt="2Eenheid"/><span>Support / Beheer</span></a></li>
   <li class=""><a href="/implementatie" src="http://www.2eenheid.de/wp-content/themes/2eenheid/images/slideshow/slideshow-5.jpg"><img src="http://www.2eenheid.de/wp-content/themes/2eenheid/images/slideshow/slideshow-5.jpg" alt="2Eenheid"/><span>Implementatie</span></a></li>
   <li class="current_page_item"><a href="/cloud" src="http://www.2eenheid.de/wp-content/themes/2eenheid/images/slideshow/slideshow-11.jpg"><img src="http://www.2eenheid.de/wp-content/themes/2eenheid/images/slideshow/slideshow-11.jpg" alt="2Eenheid"/><span>Cloud</span></a></li>
   <li class=""><a href="/webhosting-en-hosting" src="http://www.2eenheid.de/wp-content/themes/2eenheid/images/slideshow/slideshow-8.jpg"><img src="http://www.2eenheid.de/wp-content/themes/2eenheid/images/slideshow/slideshow-8.jpg" alt="2Eenheid"/><span>Webhosting / Hosting</span></a></li>
   <li class=""><a href="/unit4-multivers" src="http://www.2eenheid.de/wp-content/themes/2eenheid/images/slideshow/slideshow-2.jpg"><img src="http://www.2eenheid.de/wp-content/themes/2eenheid/images/slideshow/slideshow-2.jpg" alt="2Eenheid"/><span>Unit4 Multivers</span></a></li>
  </ul>
  </div>        
</div>  

【问题讨论】:

    标签: javascript jquery slideshow fade


    【解决方案1】:

    尝试将 pikachoose 类的不透明度设置为 1

    .pikachoose 
    {
      opacity:1 !important;
    }
    

    【讨论】:

    • 谢谢,我做到了,但现在它不再褪色了。 (效果见网站)
    • 褪色意味着图像的不透明度从 1 降低到 0,下一张图像的不透明度从 0 增加到 1....在问题中 yiu 提到你不需要褪色...所以我给出了这个解决方案......我不知道你在期待什么?
    • 哦,我确实想保持褪色,但中间没有白色背景。我用 Toggle 打错了。编辑它..
    • 褪色行为就是这样..你可能想要一些其他动画..不褪色
    【解决方案2】:

    使用 z-index 执行此操作。

    CSS

    #slideshow-main { position: relative }   
    
    .slideshow-main img {z-index: 1; position: absolute; }
    
    .slideshow-main img.active {z-index: 3; }   
    

    JQUERY

    function cycleImages(){
    
          var $active = $('#slideshow .active');
          var $next = ($active.next().length > 0) ? $active.next() : $('#slideshow img:first');
          $next.css('z-index',2);//move the next image up the pile
          $active.fadeOut(1500,function(){//fade out the top image
              $active.css('z-index',1).show().removeClass('active');//reset the z-index and unhide the image
              $next.css('z-index',3).addClass('active');//make the next image the top one
          });
        }
    $(function(){
        setInterval('cycleImages()', 10000);
    });
    

    【讨论】:

      猜你喜欢
      • 2023-03-25
      • 1970-01-01
      • 1970-01-01
      • 2012-12-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-25
      • 1970-01-01
      相关资源
      最近更新 更多