• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >jquery > jQuery+HTML5+CSS3制作支持响应式布局时间轴插件

jQuery+HTML5+CSS3制作支持响应式布局时间轴插件

作者:Jeremy阳仔 字体:[增加 减小] 来源:互联网

Jeremy阳仔 通过本文主要向大家介绍了jquery时间轴插件,jquery响应式时间轴插件,jquery时间轴等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

jQuery时间轴插件效果图预览

   (图一)   

(图二)

附注说明: 

图一是浏览器宽度像素大于560px下的展示效果,图二是在浏览器宽度像素小于560px下的展现效果。使用的是CSS3的Media Query(媒体查询)实现的效果。
 另外页面中圆形、圆角和三角同样使用了CSS3的特殊样式。这些基础的样式和效果在本文中不会赘述,不了解的童鞋可以上网搜索学习一下,很简单。 
页面上每个时间节点的展示内容提供了三种展示样式,多张图片的展示风格、单张图片的展示风格和无图片的展示风格。这些可以根据自己的需求自己更改。 

分析页面布局思路

页面的布局其实主要就是将外层的容器使用相对定位,容器内的元素使用绝对定位即可。具体的分析请看下图
 

依照图片上的分析就可以达到时间轴插件的布局展示效果。 

布局好了之后,我们就可以添加我们需要展现的内容了。为了页面不那么单调,可以使用JQuery的animate函数添加一些效果,比如可以让左侧的节点从页面左侧滑入页面,右侧节点从页面右侧滑入页面。代码简单,稍后贴出。 

加入滚动触发事件机制,动态加载时间节点 

在时间节点较多的情况下,一般情况下比如一个公司的发展历程和重大记事都不太可能只有三、五条信息吧,随着时间的推移,值得记录的大事件就会越多。如果一次就要让全部的信息展示在页面上可能会影响页面的展示效率,用户的体验也不会很好。
所以,可以利用触发滚动事件机制,每次加载固定的条数。这跟实现分页效果是一样的。只不过我们的触发条件是滚动触发。

注意事项:
1. 首次加载固定条数时,假设每次加载5条记录,如果首次加载5条后,没有出现滚动条,应该再次调用查询方法,继续加载,直到出现滚动条(否则首次加载5条后,没有出现滚动条,以后就无法触发滚动事件了,自然也就无法继续查询之后的记录了)。
2. 触发滚动事件,不能够只要滚动就触发,否则程序一直在触发加载记录方法,页面可能会无法由于频繁发送请求无法响应。解决方法,可以在滚动条滚动到页面底部的时候再触发加载记录方法。
具体的判定请看代码 

CSS代码 

.timeline-container{
  width:100%;
  /*height:auto;*/
}
.timeline{
  width:100%;
  margin:auto;
  position:relative;
  height: auto;
  padding:30px 0px 0px 0px;
}
.timeline > .timeline-block{
  width:50%;
}
.timeline-block > .popover{
  max-width: 70%;
}
.timeline > .timeline-block-odd{
  float:left;
}
.timeline > .timeline-block-even{
  float:right;
}
.timeline-block-odd>.timeline-content{
  display: block;
  position:relative;
  float:right;
  margin-right:50px;
}
.timeline-block-even>.timeline-content{
  display: block;
  float:left;
  position:relative;
  margin-left:50px;
}

.timeline-content > .arrow{
  top:20px !important;
  background: #f7f7f7;
}
.timeline-content > .popover-content{
  max-height: 240px;
  overflow-y: auto;
  color: #696969;
  font-size: 11px;
}

.timeline-content>.popover-footer{
  padding:8px 14px;
  margin:0px;
  font-size: 11px;
  border-top: 1px dotted #b9b9b9;
  color: #4b4b4b;
  background:#F2F2F2;
}
.timeline img{
  border:1px solid #dddddd;
  padding:2px;
}
.timeline-img{
  width:50px;
  height:50px;
  -webkit-border-radius: 25px;
  -moz-border-radius: 25px;
  -o-border-radius: 25px;
  border-radius: 25px;
  border:3px solid #A3E3E8;
  margin:auto;
  background: #ffffff;
  position:absolute;
  z-index: 9;
  left:50%;
  margin-left:-25px;
  background: url(../../indexImg/greeneye.jpg);
  background-size: cover;
}

.timeline-line{
  width:4px;
  height:100%;
  background: #aef0f5;
  position:absolute;
  z-index:8;
  left:50%;
  border-left:1px solid #aef0f5;
  border-right:1px solid #ffffff;
  margin-left: -2px;
  margin-top:-30px;
}

.timeline-block-odd>.popover.left>.arrow:after {
  right: 2px;
  border-left-color: #F7F7F7;
}
.timeline-block-even>.popover.right>.arrow:after {
  left: 2px;
  border-right-color: #F7F7F7;
}


/** mediaquery查询样式 **/
@media screen and (max-width: 560px){

  .timeline{
    width:100%;
    position:relative;
    height: auto;
    padding:30px 0px 0px 0px;
  }
  .timeline > .timeline-block{
    width:100%;
  }
  .timeline > .timeline-block-odd{
    float:right;
  }
  .timeline-block-odd>.timeline-content{
    display: block;
    position:relative;
    float:left;
    margin-left:75px;
  }
  .timeline-block-even>.timeline-content{
    display: block;
    position:relative;
    float:left;
    margin-left:75px;
  }

  .timeline-block-odd>.popover>.arrow, .timeline-block-odd>.popover>.arrow:after {
    position: absolute;
    display: block;
    width: 0;
    height: 0;
    border-color: transparent;
    border-style: solid;
  }
  .timeline-block-odd>.popover.left>.arrow {
    left: -21px;
    bottom: -10px;
    content: " ";
    border-left-width: 0;
    border-right-color: #999;
    border-width: 10px;
  }

  .timeline-block-odd>.popover.left>.arrow:after {
    left:1px;
    right: 1px;
    bottom: -10px;
    content: " ";
    border-left-width: 0;
    border-right-color: #fff;
  }
  .timeline-block-odd>.popover>.arrow:after {
    content: "";
    border-width: 10px;
  }

  .timeline-img{
    width:50px;
    height:50px;
    margin:auto;
    background: #ffffff;
    -webkit-border-radius: 25px;
    -moz-border-radius: 25px;
    -o-border-radius: 25px;
    border-radius: 25px;
    border:3px solid #8e8e8e;
    position:absolute;
    z-index: 9;
    left:0;
    margin-left:0px;
  }

  .timeline-line{
    width:4px;
    height:100%;
    background: #d0d0d0;
    border-left:1px solid #ececec;
    border-right:1px solid #ececec;
    position:absolute;
    z-index:8;
    left:0;
    margin-left: 24px;
    margin-top:-30px;
  }


}

JQuery代码 

$(function(){
  var _timeline_row_ = $("<div></div>").addClass("row");
  $(".timeline-container").append(_timeline_row_);
  var loadData=function(){
    $.getJSON("timeline.json", function (data) {
      $.each(data, function (i, tl) {
        var _timeline_ = $("<div></div>").addClass("timeline");
        _timeline_row_.append(_timeline_);

        var _time_block_ = $("<div></div>").addClass("timeline-block");
        var _time_content_ = $("<div></div>").addClass("popover timeline-content");
        _time_block_.append(_time_content_);
        /**
         * 设置显示内容
         */

        var _popover_title_ = $("<h3></h3>").addClass("popover-title").text(tl["diagTime"]);
        var _popover_footer_ = $("<div></div>").addClass("popover-footer").text(tl["result"]);
        var _popover_content_ = $("<div></div>").addClass("popover-content");
        _time_content_.append($("<div></div>").addClass("arrow"))
          .append(_popover_title_)
          .append(_popover_content_)
          .append(_popover_footer_);
        /**
         * 主页展示内容布局
         */

        if (tl["images"].length > 1 && tl["images"] != "" && tl["images"] != null && tl["images"] != "undefined") {
          var _img_container_ = $("<div></div>").css("margin-bottom", "10px");
          var _table_container_ = $("<table></table>").addClass("table table-bordered table-condensed");
          for (var m = 0; m < tl["images"].length; m++) {
            _img_container_.append($("<img/>").attr("src"



 
分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • jQuery+HTML5+CSS3制作支持响应式布局时间轴插件
  • Jquery时间轴特效(三种不同类型)

相关文章

  • jQuery代码实现实时获取时间
  • jQuery学习笔记之回调函数
  • jquery select选中的一个小问题
  • jQuery前台数据获取实现代码
  • 使用jQuery mobile库检测url绝对地址和相对地址的方法
  • jQuery中outerWidth()方法用法实例
  • 浅析jquery数组删除指定元素的方法:grep()
  • jQuery实现倒计时(倒计时年月日可自己输入)
  • jQuery EasyUI基础教程之EasyUI常用组件(推荐)
  • jquery使用animate方法实现控制元素移动

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • JQuery跳出each循环的方法
    • jquery实现全选、反选、获得所有选中的checkbox
    • 如何使用jquery实现文字上下滚动效果
    • 基于jquery的修改当前TAB显示标题的代码
    • 使用jquery实现简单的ajax
    • 解析jquery中的ajax缓存问题
    • 关于用Jquery的height()、width()计算动态插入的IMG标签的宽高的问题
    • 分享精心挑选的23款美轮美奂的jQuery 图片特效插件
    • jQuery动画效果相关方法实例分析
    • 老生常谈combobox和combotree模糊查询

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有