web299.com
全部
教育
语言/资格考试
法律
互联网
政务民生
Word模板
Excel模板
PPT模板
网页特效
小程序模板
网站模板
首页
教育
语言/资格考试
法律
互联网
政务民生
Word模板
Excel模板
PPT模板
网页特效
小程序模板
网站模板
当前位置:
首页
>
网页特效
>
表格
jQuery和css3响应式斑马线表格美化插件
分类:
表格
日期:
2024-05-14
点击(2)
评论(0)
演 示
免费下载
简介
我们使用一个section来作为表格结构。header 中包含的是表格的第一列,没有将header和其它列放在同一个div中的原因是:在手机上header是fixed的。它的父元素将决定它在section中的位置。 ```html
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来在小屏幕设备上去掉表格右边的小箭头。 ```html 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(); }); }); ```
相关推荐
html5浪漫粒子表白文字特效
SlidesJS幻灯片特效
html5瀑布流相册特效
css3 svg实现的情人节表白鲜花动画特效
t-scroll.js基于ES6的DOM元素,过渡动画库插件
纯js写省市区三级联动效果
广告
广告