animate.css官網(wǎng)網(wǎng)頁模塊漸入效果

image.png

前提是引用animate.css
html代碼:
例如,在想要漸入的元素塊上添加‘a(chǎn)nimated’,在屬性type中添加你想要的漸入效果‘slideInLeft’

<div class="project animated" type="slideInLeft" id="story">
</div>
<div class="project animated" type="slideInDown" id="activity">
</div>

css代碼

 .animated{
            visibility: hidden;
        }
        .animated.in{
            visibility: visible;
        }

js代碼

    var animateArr = [];

    $('.animated').each(function (k,v) {
    animateArr.push($(v).offset().top);
    });

   var thisDivIndex = 0;
   $(window).scroll(function () {
       var glt = animateArr[0]+700;
        var lt = animateArr[0]+500;
       if(($(window).scrollTop()>lt)&&($(window).scrollTop()<glt)){
           var thisDiv =  $($('.animated')[thisDivIndex]);
           var animateCss = thisDiv.attr('type');
           thisDiv.removeClass(animateCss);
           thisDiv.addClass(animateCss);
           thisDiv.addClass('in');
           animateArr.splice(0,1);
           thisDivIndex++;
       }
   });

貼這些代碼進去,就ok啦!

?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

  • 在AngularJS應用中創(chuàng)建動畫,有三種途徑: 使用CSS3動畫 使用JavaScript動畫 使用CSS3過渡...
    oWSQo閱讀 1,564評論 0 3
  • 一個得了重病的小女孩,當她每次看到窗外的樹葉往下落時,她告訴自己,秋天來了,當所有的葉子落完的時候,自己也將離開這...
    青芒護膚閱讀 1,119評論 0 2
  • 街拍達人 MillyQ 穿搭主題 好的,就來個霸氣點的,一抹紅唇向來都是加分的亮點配件。然后最近,對帽子有點癡狂,...
    STYLEMIXER閱讀 3,071評論 10 27
  • 我希望 你所遇見的 和我預期的,還算順利 我希望 你所鐘愛的 是一位溫柔的人 我希望 你所幸福的 關乎愛情,生活,...
    阿琴姑娘閱讀 1,259評論 30 111
  • 多彩童年,魅力校園 ----城關六小社團活動成果展五月的臨潭,草木繁盛,鳥語花香;五月的六小...
    西環(huán)房客閱讀 371評論 0 1

友情鏈接更多精彩內(nèi)容