[CSS3] Responsive Table -- no more table
When the screen size is small, we can use "no more table" solution. So instead of render table is row layout, we render it in column layout.
Given the table below:
<table> <thead> <tr> <th>Team</th> <th>1st</th> <th>2nd</th> <th>3rd</th> <th>4th</th> <th>5th</th> <th>6th</th> <th>7th</th> <th>8th</th> <th>9th</th> <th>Final</th> </tr> </thead> <tbody> <tr> <td data-th="Team">Toronto</td> <td data-th="1st">0</td> <td data-th="2nd">0</td> <td data-th="3rd">0</td> <td data-th="4th">4</td> <td data-th="5th">0</td> <td data-th="6th">1</td> <td data-th="7th">0</td> <td data-th="8th">0</td> <td data-th="9th">0</td> <td data-th="Final">5</td> </tr> <tr> <td data-th="Team">San Francisco</td> <td data-th="1st">0</td> <td data-th="2nd">0</td> <td data-th="3rd">0</td> <td data-th="4th">4</td> <td data-th="5th">0</td> <td data-th="6th">0</td> <td data-th="7th">0</td> <td data-th="8th">0</td> <td data-th="9th">0</td> <td data-th="Final">4</td> </tr> </tbody>
1. Reset table relatede element to block element:
table, thead, tbody, th, td, tr { display: block; }
2. Remove the thead:
thead tr { position: absolute; top: -9999px; left: -9999px; }
3. Position layout:
/*The actually content will be on the right side*/ td { position: relative; padding-left: 50%; } /*Using data-th to set the value and set position to left*/ td:before { position: absolute; left: 6px; content: attr(data-th); font-weight: bold; }
Full example:
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
2017-02-20 [Angular] @ViewChild and template #refs to get Element Ref
2017-02-20 [Angular] @ViewChildren and QueryLists (ngAfterViewInit)
2017-02-20 [Angular] Difference between Providers and ViewProviders
2016-02-20 [Protractor] Use protractor to catch errors in the console
2016-02-20 [Cycle.js] Hyperscript as our alternative to template languages