jQuery表格美化行插件响应式表格

下载地址

真正响应式的jQuery和css3斑马线表格美化插件。该表格插件使用无序列表制作,并有响应式、隔行变色斑马线、适用于移动设备等特定。表格式网页设计中的一个重要元素,它们能够让用户直观的了解某些数据。在这个demo中使用的表格不是标准的表格html结构,而是使用无序列表来制作表格。这样做的目的是为了使表格具有很好的相应性。HTML结构我们使用一个section来作为表格结构。header 中包含的是表格的第一列,没有将header和其它列放在同一个div中的原因是:在手机上header是fixed的。它的父元素将决定它在section中的位置。

Features

  • Feature 1
  • Feature 2
  • ...

Plan 1

  • 1 GB
  • 2
  • ...

Plan 2

  • 2 GB
  • 5
  • ...

CSS样式CSS文件中有一点要指出的是:我们使用2个div来包裹表格列(.cd-table-container 和 .cd-table-wrapper )。为什么需要两个div呢?因为第一个div这里设置它的宽度为90%和一个overflow-x:auto。第二个div的宽度是整个表格的宽度。通过这种方法,我们能让屏幕右边有一些margin,从而在表格宽度大于90%时让表格内容滚动起来。JAVASCRIPT在demo中仅使用jQuery来在小屏幕设备上去掉表格右边的小箭头。jQuery(document).ready(function($){ var $columns_number = $("#cd-table .cd-table-container").find(".cd-table-column").length; $(".cd-table-container").on("scroll", function(){ $this = $(this); //hide the arrow on scrolling if( $this.scrollLeft() > 0 ) { $(".cd-scroll-right").hide(); } //remove color gradient when table has scrolled to the end var total_table_width = parseInt($(".cd-table-wrapper").css("width").replace("px", "")), table_viewport = parseInt($("#cd-table").css("width").replace("px", "")); if( $this.scrollLeft() >= total_table_width - table_viewport - $columns_number) { $("#cd-table").addClass("table-end"); } else { $("#cd-table").removeClass("table-end"); } }); //scroll the table (scroll value equal to column width) when clicking on the .cd-scroll-right arrow $(".cd-scroll-right").on("click", function(){ $this= $(this); var column_width = $(this).siblings(".cd-table-container").find(".cd-table-column").eq(0).css("width").replace("px", ""), new_left_scroll = parseInt($(".cd-table-container").scrollLeft()) + parseInt(column_width); $(".cd-table-container").animate( {scrollLeft: new_left_scroll}, 200 ); $this.hide(); });});

2f42b5681cd7cf5d9ffdef14c3f0747b9760.jpg

dd:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值