jQuery垂直滾動時間軸插件



67 267 90



特效描述:jQuery 垂直滾動時間軸,jQuery垂直滾動時間軸插件

代碼結構

1. 引入JS

<script type="text/javascript" src="js/jquery.min.js"></script>

2. HTML代碼

<ul class="timeline">
  <li class="bar"></li>
</ul>
<div class="container">
  <section data-name="首頁">
    <h1>首頁</h1>
    <h2>51前端</h2>
    </p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima exercitationem earum beatae assumenda debitis quibusdam, ducimus autem a ab nisi, praesentium et enim numquam consequatur similique quis consectetur consequuntur iure!
    </p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima exercitationem earum beatae assumenda debitis quibusdam, ducimus autem a ab nisi, praesentium et enim numquam consequatur similique quis consectetur consequuntur iure!
    </p>
  </section>
  <section data-name="公司介紹">
    <h1>公司介紹</h1>
    <h2>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate porro odit esse ut quidem deleniti dolore doloremque aliquam neque ad at optio odio quasi aperiam necessitatibus reiciendis, quaerat quod autem.</h2>
    <img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=Placeholder&w=1800&h=600" alt="" />
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima exercitationem earum beatae assumenda debitis quibusdam, ducimus autem a ab nisi, praesentium et enim numquam consequatur similique quis consectetur consequuntur iure!
    </p>
    <h1>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate porro odit esse ut quidem deleniti dolore doloremque aliquam neque ad at optio odio quasi aperiam necessitatibus reiciendis, quaerat quod autem.</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima exercitationem earum beatae assumenda debitis quibusdam, ducimus autem a ab nisi, praesentium et enim numquam consequatur similique quis consectetur consequuntur iure!
      <br>
      <img src="https://placeholdit.imgix.net/~text?txtsize=33&txt=Placeholder&w=1800&h=600" alt="" />
    </p>
    <h1>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate porro odit esse ut quidem deleniti dolore doloremque aliquam neque ad at optio odio quasi aperiam necessitatibus reiciendis, quaerat quod autem.</h1>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima exercitationem earum beatae assumenda debitis quibusdam, ducimus autem a ab nisi, praesentium et enim numquam consequatur similique quis consectetur consequuntur iure!
    </p>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima exercitationem earum beatae assumenda debitis quibusdam, ducimus autem a ab nisi, praesentium et enim numquam consequatur similique quis consectetur consequuntur iure!
    </p>
    <h1>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate porro odit esse ut quidem deleniti dolore doloremque aliquam neque ad at optio odio quasi aperiam necessitatibus reiciendis, quaerat quod autem.</h1>
  </section>
  <section data-name="案例">
    <h1>案例</h1>
    <h2>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate porro odit esse ut quidem deleniti dolore doloremque aliquam neque ad at optio odio quasi aperiam necessitatibus reiciendis, quaerat quod autem.</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Minima exercitationem earum beatae assumenda debitis quibusdam, ducimus autem a ab nisi, praesentium et enim numquam consequatur similique quis consectetur consequuntur iure!
    </p>
  </section>
  <section data-name="招聘中心">
    <h1>招聘中心</h1>
    <h2>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate porro odit esse ut quidem deleniti dolore doloremque aliquam neque ad at optio odio quasi aperiam necessitatibus reiciendis, quaerat quod autem.</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
    </p>
  </section>
  <section data-name="關于我們">
    <h1>關于我們</h1>
    <h2>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate porro odit esse ut quidem deleniti dolore doloremque aliquam neque ad at optio odio quasi aperiam necessitatibus reiciendis, quaerat quod autem.</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
    </p>
  </section>
  <section data-name="聯系我們">
    <h1>聯系我們</h1>
    <h2>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Voluptate porro odit esse ut quidem deleniti dolore doloremque aliquam neque ad at optio odio quasi aperiam necessitatibus reiciendis, quaerat quod autem.</h2>
    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.
    </p>
  </section>
</div>
<script>
"use strict";
$(function () {
  function sumSection() {
    return $(".container").height();
  }
  function setDimensionBar() {
    $(".bar").css({
      "height": $(window).height() / sumSection() * 100 + "%"
    });
  }
  function setSection() {
    $.each($("section"), function (i, element) {
      $(element).css({
        "min-height": $(window).height()
      });
    });
  }
  function addBehaviours() {
    var sections = $("section");
    $.each($(".node"), function (i, element) {
      $(element).on("click", function (e) {
        e.preventDefault();
        var scroll = $(sections[i]).offset().top;
        $('html, body').animate({
          scrollTop: scroll
        }, 500);
      });
    });
  }
  function arrangeNodes() {
    $(".node").remove();
    $.each($("section"), function (i, element) {
      var name = $(element).data("name");
      var node = $("<li class='node'><span>" + name + "</span></li>");
      $(".timeline").append(node);
      $(node).css({
        "top": $(".timeline").height() / $(document).height() * $(element).offset().top
      });
    });
    addBehaviours();
  }
  $(window).on("scroll", function () {
    var top = window.scrollY / sumSection() * 100;
    $(".bar").css({
      "top": top + "%"
    });
  });
  $(window).on("resize", function () {
    setSection();
    arrangeNodes();
    setDimensionBar();
  });
  setTimeout(function () {
    setSection();
    arrangeNodes();
    setDimensionBar();
  }, 200);
});
</script>



用戶評論
大牛,別默默的看了,快登錄幫我點評一下吧!:)      登錄 | 注冊


熱門標簽: 文字疊加 文字層疊 滾動 滾動條 頁面滾動 滾動插件 滾動條插件 滾動條美化 文字翻轉 文字旋轉 文字全屏 文字淡出淡進 文字淡出 文字淡進 文字延遲加載 文字延遲 文字加載 文字放大縮小 文字縮放 文字大小 文字放大 文字縮小 文字變大 文字變小 文字收縮展開 文字收縮 文字展開 文字提示框 提示文字 文字拖動 文字拖拽 360全景 360度全景 h5文字動畫 h5文字邊框動畫 html5文字動畫 html5文字邊框動畫 文字切換 文字選項卡 文字滑動 文字滑塊 文字滾動 文字無縫滾動 文字間歇滾動 自動滾動圖片輪播 圖片文字 文字導航菜單 文字導航 文字菜單 日期時間 時鐘 日歷 時間 日歷插件 時間日期插件 文字 文字插件 時間軸 豎直時間軸 橫向時間軸 文字列表 全屏滾動
?
×
×

注冊

官方QQ群

掃描上面二維碼加微信群

官方QQ群

jQuery/js討論群
群號:642649996
Css3+Html5討論群
群號:322131262

加群請備注:從官網了解到

老夫子电子