一款基於jquery超炫的圖片切換特效

來源:互聯網
上載者:User

標籤:des   style   blog   http   color   io   ar   2014   art   

今天為給大家介紹一款基於jquery超炫的圖片切換特效。由百葉窗飛入顯示圖片。圖片訊息的時候也是百葉窗漸行漸遠。用於圖片展示,效果還是非常好,我們一起看下:

 

線上預覽   源碼下載

 

來看下實現的代碼。注意了,這裡有引用jquery和underscore外掛程式。

html代碼:

 <div class="wrap">        <div class="box active" style="background-image: url(img/1.jpg);">        </div>        <div class="box active" style="background-image: url(img/1.jpg);">        </div>        <div class="box active" style="background-image: url(img/1.jpg);">        </div>        <div class="box active" style="background-image: url(img/1.jpg);">        </div>        <div class="box active" style="background-image: url(img/1.jpg);">        </div></div>

js代碼:

 var imgArr = [  ‘img/1.jpg‘,  ‘img/2.jpg‘,  ‘img/3.jpg‘,  ‘img/4.jpg‘,  ‘img/5.jpg‘,  ‘img/6.jpg‘,  ‘img/7.jpg‘,  ‘img/8.jpg‘,  ‘img/9.jpg‘,  ‘img/10.jpg‘,  ‘img/11.jpg‘];        var speed = 2;        var firstPass = true;        function goGoGo() {            var transSpeed = firstPass === true ? 0 : speed;            firstPass = false;            function makeActive() {                $(‘.box‘)      .addClass(‘active‘)      .css({          ‘background-image‘: ‘url(‘ + imgArr[_.random(0, imgArr.length - 1)] + ‘)‘      });            }            $(‘.box.active‘).removeClass(‘active‘);            setTimeout(makeActive, transSpeed * 1000);        }        setTimeout(goGoGo, 1000);        setInterval(goGoGo, 7000);

一款基於jquery超炫的圖片切換特效

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.