jQuery垂直滚动时间轴插件



62 246 83



特效描述: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

加群请备注:从官网了解到