[转]Responsive Tables Demo
本文转自:http://elvery.net/demo/responsive-tables/
A quick and dirty look at some techniques for designing responsive table layouts. This was put together in haste (and with the aid of Twitter Bootstrap) for What Do You Know Brisbane hosted by Web Directions.
I work for a really great little web design agency in Brisbane, and you should say hello.
The Unseen Column
This technique, first described by Stuart Curry (@irishstu) involves simply hiding less important columns on smaller screen sizes.
Example
| Code | Company | Price | Change | Change % | Open | High | Low | Volume |
|---|---|---|---|---|---|---|---|---|
| AAC | AUSTRALIAN AGRICULTURAL COMPANY LIMITED. | $1.38 | -0.01 | -0.36% | $1.39 | $1.39 | $1.38 | 9,395 |
| AAD | ARDENT LEISURE GROUP | $1.15 | +0.02 | 1.32% | $1.14 | $1.15 | $1.13 | 56,431 |
| AAX | AUSENCO LIMITED | $4.00 | -0.04 | -0.99% | $4.01 | $4.05 | $4.00 | 90,641 |
| ABC | ADELAIDE BRIGHTON LIMITED | $3.00 | +0.06 | 2.04% | $2.98 | $3.00 | $2.96 | 862,518 |
| ABP | ABACUS PROPERTY GROUP | $1.91 | 0.00 | 0.00% | $1.92 | $1.93 | $1.90 | 595,701 |
| ABY | ADITYA BIRLA MINERALS LIMITED | $0.77 | +0.02 | 2.00% | $0.76 | $0.77 | $0.76 | 54,567 |
| ACR | ACRUX LIMITED | $3.71 | +0.01 | 0.14% | $3.70 | $3.72 | $3.68 | 191,373 |
| ADU | ADAMUS RESOURCES LIMITED | $0.72 | 0.00 | 0.00% | $0.73 | $0.74 | $0.72 | 8,602,291 |
| AGG | ANGLOGOLD ASHANTI LIMITED | $7.81 | -0.22 | -2.74% | $7.82 | $7.82 | $7.81 | 148 |
| AGK | AGL ENERGY LIMITED | $13.82 | +0.02 | 0.14% | $13.83 | $13.83 | $13.67 | 846,403 |
| AGO | ATLAS IRON LIMITED | $3.17 | -0.02 | -0.47% | $3.11 | $3.22 | $3.10 | 5,416,303 |
Code
The approach I've presented here assumes you know the index of the columns to be hidden. This probably isn't always appropriate, and isn't all that semantic. Another option is to give the <th> and <td> classes based on importance level and code your CSS accordingly.
- <table>
- <thead>
- <tr>
- <th>Code</th>
- <th>Company</th>
- <th class="numeric">Price</th>
- <th class="numeric">Change</th>
- <th class="numeric">Change %</th>
- <th class="numeric">Open</th>
- <th class="numeric">High</th>
- <th class="numeric">Low</th>
- <th class="numeric">Volume</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>AAC</td>
- <td>AUSTRALIAN AGRICULTURAL COMPANY LIMITED.</td>
- <td class="numeric">$1.38</td>
- <td class="numeric">-0.01</td>
- <td class="numeric">-0.36%</td>
- <td class="numeric">$1.39</td>
- <td class="numeric">$1.39</td>
- <td class="numeric">$1.38</td>
- <td class="numeric">9,395</td>
- </tr>
- </tbody>
- </table>
- @media only screen and (max-width: 800px) {
- #unseen table td:nth-child(2),
- #unseen table th:nth-child(2) {display: none;}
- }
- @media only screen and (max-width: 640px) {
- #unseen table td:nth-child(4),
- #unseen table th:nth-child(4),
- #unseen table td:nth-child(7),
- #unseen table th:nth-child(7),
- #unseen table td:nth-child(8),
- #unseen table th:nth-child(8){display: none;}
- }
Flip Scroll
This technique was first published by David Bushell (@dbushell). For the full low down on this technique visit his post on the technique, Responsive Tables (2). While you're there, it's also worth checking out his responsive calendar proof of concept.
Example
| Code | Company | Price | Change | Change % | Open | High | Low | Volume |
|---|---|---|---|---|---|---|---|---|
| AAC | AUSTRALIAN AGRICULTURAL COMPANY LIMITED. | $1.38 | -0.01 | -0.36% | $1.39 | $1.39 | $1.38 | 9,395 |
| AAD | ARDENT LEISURE GROUP | $1.15 | +0.02 | 1.32% | $1.14 | $1.15 | $1.13 | 56,431 |
| AAX | AUSENCO LIMITED | $4.00 | -0.04 | -0.99% | $4.01 | $4.05 | $4.00 | 90,641 |
| ABC | ADELAIDE BRIGHTON LIMITED | $3.00 | +0.06 | 2.04% | $2.98 | $3.00 | $2.96 | 862,518 |
| ABP | ABACUS PROPERTY GROUP | $1.91 | 0.00 | 0.00% | $1.92 | $1.93 | $1.90 | 595,701 |
| ABY | ADITYA BIRLA MINERALS LIMITED | $0.77 | +0.02 | 2.00% | $0.76 | $0.77 | $0.76 | 54,567 |
| ACR | ACRUX LIMITED | $3.71 | +0.01 | 0.14% | $3.70 | $3.72 | $3.68 | 191,373 |
| ADU | ADAMUS RESOURCES LIMITED | $0.72 | 0.00 | 0.00% | $0.73 | $0.74 | $0.72 | 8,602,291 |
| AGG | ANGLOGOLD ASHANTI LIMITED | $7.81 | -0.22 | -2.74% | $7.82 | $7.82 | $7.81 | 148 |
| AGK | AGL ENERGY LIMITED | $13.82 | +0.02 | 0.14% | $13.83 | $13.83 | $13.67 | 846,403 |
| AGO | ATLAS IRON LIMITED | $3.17 | -0.02 | -0.47% | $3.11 | $3.22 | $3.10 | 5,416,303 |
Code
The biggest trick to getting this working is to use display: inline-block; on the table rows and white-space: nowrap; on the table body. You'll also need to make use of your favourite float clearing method.
- <table>
- <thead>
- <tr>
- <th>Code</th>
- <th>Company</th>
- <th class="numeric">Price</th>
- <th class="numeric">Change</th>
- <th class="numeric">Change %</th>
- <th class="numeric">Open</th>
- <th class="numeric">High</th>
- <th class="numeric">Low</th>
- <th class="numeric">Volume</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>AAC</td>
- <td>AUSTRALIAN AGRICULTURAL COMPANY LIMITED.</td>
- <td class="numeric">$1.38</td>
- <td class="numeric">-0.01</td>
- <td class="numeric">-0.36%</td>
- <td class="numeric">$1.39</td>
- <td class="numeric">$1.39</td>
- <td class="numeric">$1.38</td>
- <td class="numeric">9,395</td>
- </tr>
- </tbody>
- </table>
- @media only screen and (max-width: 800px) {
- #flip-scroll .cf:after { visibility: hidden; display: block; font-size: 0; content: " "; clear: both; height: 0; }
- #flip-scroll * html .cf { zoom: 1; }
- #flip-scroll *:first-child+html .cf { zoom: 1; }
- #flip-scroll table { width: 100%; border-collapse: collapse; border-spacing: 0; }
- #flip-scroll th,
- #flip-scroll td { margin: 0; vertical-align: top; }
- #flip-scroll th { text-align: left; }
- #flip-scroll table { display: block; position: relative; width: 100%; }
- #flip-scroll thead { display: block; float: left; }
- #flip-scroll tbody { display: block; width: auto; position: relative; overflow-x: auto; white-space: nowrap; }
- #flip-scroll thead tr { display: block; }
- #flip-scroll th { display: block; text-align: right; }
- #flip-scroll tbody tr { display: inline-block; vertical-align: top; }
- #flip-scroll td { display: block; min-height: 1.25em; text-align: left; }
- /* sort out borders */
- #flip-scroll th { border-bottom: 0; border-left: 0; }
- #flip-scroll td { border-left: 0; border-right: 0; border-bottom: 0; }
- #flip-scroll tbody tr { border-left: 1px solid #babcbf; }
- #flip-scroll th:last-child,
- #flip-scroll td:last-child { border-bottom: 1px solid #babcbf; }
- }
No More Tables
This technique was developed by Chris Coyier (@chriscoyier) and described in his post Responsive Data Tables at css-tricks.com. While you're there, you should probably check out the Responsive Tables Roundup post, which showcases all these techniques and more.
Example
| Code | Company | Price | Change | Change % | Open | High | Low | Volume |
|---|---|---|---|---|---|---|---|---|
| AAC | AUSTRALIAN AGRICULTURAL COMPANY LIMITED. | $1.38 | -0.01 | -0.36% | $1.39 | $1.39 | $1.38 | 9,395 |
| AAD | ARDENT LEISURE GROUP | $1.15 | +0.02 | 1.32% | $1.14 | $1.15 | $1.13 | 56,431 |
| AAX | AUSENCO LIMITED | $4.00 | -0.04 | -0.99% | $4.01 | $4.05 | $4.00 | 90,641 |
| ABC | ADELAIDE BRIGHTON LIMITED | $3.00 | +0.06 | 2.04% | $2.98 | $3.00 | $2.96 | 862,518 |
| ABP | ABACUS PROPERTY GROUP | $1.91 | 0.00 | 0.00% | $1.92 | $1.93 | $1.90 | 595,701 |
| ABY | ADITYA BIRLA MINERALS LIMITED | $0.77 | +0.02 | 2.00% | $0.76 | $0.77 | $0.76 | 54,567 |
| ACR | ACRUX LIMITED | $3.71 | +0.01 | 0.14% | $3.70 | $3.72 | $3.68 | 191,373 |
| ADU | ADAMUS RESOURCES LIMITED | $0.72 | 0.00 | 0.00% | $0.73 | $0.74 | $0.72 | 8,602,291 |
| AGG | ANGLOGOLD ASHANTI LIMITED | $7.81 | -0.22 | -2.74% | $7.82 | $7.82 | $7.81 | 148 |
| AGK | AGL ENERGY LIMITED | $13.82 | +0.02 | 0.14% | $13.83 | $13.83 | $13.67 | 846,403 |
| AGO | ATLAS IRON LIMITED | $3.17 | -0.02 | -0.47% | $3.11 | $3.22 | $3.10 | 5,416,303 |
Code
This technique as presented here relies on using HTML5 data attributes and accessing them via CSS to specify the column headings. The other option is to hard code the column headings into the CSS, but as we all know content in CSS is a huge no-no.
- <table>
- <thead>
- <tr>
- <th>Code</th>
- <th>Company</th>
- <th class="numeric">Price</th>
- <th class="numeric">Change</th>
- <th class="numeric">Change %</th>
- <th class="numeric">Open</th>
- <th class="numeric">High</th>
- <th class="numeric">Low</th>
- <th class="numeric">Volume</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td data-title="Code">AAC</td>
- <td data-title="Company">AUSTRALIAN AGRICULTURAL COMPANY LIMITED.</td>
- <td data-title="Price" class="numeric">$1.38</td>
- <td data-title="Change" class="numeric">-0.01</td>
- <td data-title="Change %" class="numeric">-0.36%</td>
- <td data-title="Open" class="numeric">$1.39</td>
- <td data-title="High" class="numeric">$1.39</td>
- <td data-title="Low" class="numeric">$1.38</td>
- <td data-title="Volume" class="numeric">9,395</td>
- </tr>
- </tbody>
- </table>
- @media only screen and (max-width: 800px) {
- /* Force table to not be like tables anymore */
- #no-more-tables table,
- #no-more-tables thead,
- #no-more-tables tbody,
- #no-more-tables th,
- #no-more-tables td,
- #no-more-tables tr {
- display: block;
- }
- /* Hide table headers (but not display: none;, for accessibility) */
- #no-more-tables thead tr {
- position: absolute;
- top: -9999px;
- left: -9999px;
- }
- #no-more-tables tr { border: 1px solid #ccc; }
- #no-more-tables td {
- /* Behave like a "row" */
- border: none;
- border-bottom: 1px solid #eee;
- position: relative;
- padding-left: 50%;
- white-space: normal;
- text-align:left;
- }
- #no-more-tables td:before {
- /* Now like a table header */
- position: absolute;
- /* Top/left values mimic padding */
- top: 6px;
- left: 6px;
- width: 45%;
- padding-right: 10px;
- white-space: nowrap;
- text-align:left;
- font-weight: bold;
- }
- /*
- Label the data
- */
- #no-more-tables td:before { content: attr(data-title); }
- }
[转]Responsive Tables Demo的更多相关文章
- [转]响应式表格jQuery插件 – Responsive tables
本文转自:http://www.shejidaren.com/responsive-tables-for-bootstrap-3.html 这个Responsive tables jQuery插件依赖 ...
- responsive tables
以上内容原本是整理为ppt格式的,贴过来格式有点乱,请见谅. 其他responsive tables参考: http://gergeo.se/RWD-Table-Patterns/ 3种类型的代码参考 ...
- Frontend Development
原文链接: https://github.com/dypsilon/frontend-dev-bookmarks Frontend Development Looking for something ...
- IOS开发--UI进阶之iCarousel学习(待翻译)
前言:先展示这个会被多个项目用到的开源的轮播器的其中一个动画效果: 更多的效果请到github原网址查看:https://github.com/nicklockwood/iCarousel 源码也可以 ...
- .Net程序员学用Oracle系列(19):我知道的导出和导入
1.传统的导出/导入工具 1.1.EXP 命令详解 1.2.IMP 命令详解 1.3.EXP/IMP 使用技巧 2.新的导出/导入工具 2.1.EXPDP/IMPDP 参数说明 2.2.EXPDP/I ...
- .Net程序员学用Oracle系列(19):导出、导入(备份、还原)
1.传统的导出/导入工具 1.1.EXP 命令详解 1.2.IMP 命令详解 1.3.EXP/IMP 使用技巧 2.新的导出/导入工具 2.1.EXPDP/IMPDP 参数说明 2.2.EXPDP/I ...
- 使用Bootstrap 基于MVC输出移动化table 列表
基于Bootrap的列表组及栅格布局来实现 模型定义 public class StreetEvent { public int Id { get; set; } public string Stre ...
- 容器,表格 ,div,元素可左右拖动,滚动 css
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...
- amazeui学习笔记--css(HTML元素5)--表格Table
amazeui学习笔记--css(HTML元素5)--表格Table 一.总结 1.基本样式:am-table:直接模块名 <table class="am-table"& ...
随机推荐
- VS "15" 预览 5 中 VB 15 新增的功能
VS "15" 预览 5 给 VB 带来了更新.这次的更新内容有3个: * 值元组 ValueTuple这个功能能把一组计算结果成组返回.为了使用这个功能,我们要安装 System ...
- How to create water Ripple effect using HTML5 canvas
https://www.script-tutorials.com/how-to-create-water-drops-effect-using-html5-canvas/ https://www.sc ...
- WebGL/X3DOM 跑在 iOS
iOS是最早支持WebGL的移动操作系统之一,我们一直在努力让X3DOM运行在那些设备上.然而,标准的Safari浏览器默认是没有开启的.这种情况从iOS8发生改变,iOS8现在完全支持WebGL - ...
- DistributedCache小记
一.DistributedCache简介 DistributedCache是hadoop框架提供的一种机制,可以将job指定的文件,在job执行前,先行分发到task执行的机器上,并有相关机制对cac ...
- FL2440驱动添加(2): RTC(Real time clock)
一,Linux下的时间分为两种,系统时间与硬件时间(RTC芯片): 1,系统时间就是运行系统能够直接看到的时间: 2,硬件时间就是RTC芯片中的时间,断电任然有电池供电: linux系统开机时,会从R ...
- 使用tinypng优化Android的资源图片
tinypng 是一个支持压缩png和jpg图片格式的网站,通过其独特的算法(通过一种叫“量化”的技术,把原本png文件的24位真彩色压缩为8位的索引演示,是一 种矢量压缩方法,把颜色值用数值123等 ...
- Iterator 迭代器(一)
迭代器(iterator)是一种对象,它能够用来遍历标准模板库容器中的部分或全部元素,每个迭代器对象代表容器中的确定的地址.迭代器修改了常规指针的接口,所谓迭代器是一种概念上的抽象:那些行为 ...
- Fragments之间的交互(实现参数传递)
Fragments之间的交互(实现参数传递) 日常开发中,通常Fragments之间可能需要交互,比如基于用户事件改变Fragment的内容.所有Fragment之间的交互需要通过他们关联的Activ ...
- Silverlight项目笔记6:Linq求差集、交集&检查网络连接状态&重载构造函数复用窗口
1.使用Linq求差集.交集 使用场景: 需要从数据中心获得用户数据,并以此为标准,同步系统的用户信息,对系统中多余的用户进行删除操作,缺失的用户进行添加操作,对信息更新了的用户进行编辑操作更新. 所 ...
- 深入理解java虚拟机(4)---类加载机制
类加载的过程包括: 加载class到内存,数据校验,转换和解析,初始化,使用using和卸载unloading过程. 除了解析阶段,其他过程的顺序是固定的.解析可以放在初始化之后,目的就是为了支持动态 ...