简体   繁体   English

表行(tr)分隔和边框

[英]Table row (tr) separation and border

I have a styling issue with tables. 我有表格的样式问题。

I need the following: 我需要以下内容:

  • responsive tables (on mobile some cells collapse) 响应表(在移动设备上一些单元格崩溃)
  • separation between table rows 表行之间的分隔
  • border between table rows 表行之间的边界
  • can't assume anything about table row height 不能假设表行高度

Something like this: 像这样的东西:

image: 图片:

在此输入图像描述

for reference check this fiddle: http://jsfiddle.net/m15rccmr/ 供参考检查这个小提琴: http//jsfiddle.net/m15rccmr/

 table{ width: 100%; border-collapse: separate; border-spacing: 0 30px; } tr{ border-bottom: 1px solid red; } .mobile-fold{ display:block; } @media (min-width: 800px){ .mobile-fold{ display:table-cell; } } 
 <table> <tbody> <tr> <td>first</td> <td class="mobile-fold">second</td> <td class="mobile-fold">third</td> </tr> <tr> <td>first</td> <td class="mobile-fold">second</td> <td class="mobile-fold">third</td> </tr> <tr> <td>first</td> <td class="mobile-fold">second</td> <td class="mobile-fold">third</td> </tr> </tbody> </table> 

I need to add a border between the table rows, and it should display fine on mobile and desktop. 我需要在表格行之间添加一个边框,它应该在移动设备和桌面上显示正常。

Any ideas? 有任何想法吗?

I think this is what you are after 我想这就是你所追求的

JSfiddle Demo JSfiddle演示

 table { width: 100%; border-collapse: separate; border-spacing: 0 30px; } td { border-bottom: 1px solid red; } td:nth-of-type(2) { border: none; } .mobile-fold { display: block; } @media (min-width: 800px) { .mobile-fold { display: table-cell; } td:nth-of-type(2) { border-bottom: 1px solid red; } } 
 <table> <tbody> <tr> <td>first</td> <td class="mobile-fold">second</td> <td class="mobile-fold">third</td> </tr> <tr> <td>first</td> <td class="mobile-fold">second</td> <td class="mobile-fold">third</td> </tr> <tr> <td>first</td> <td class="mobile-fold">second</td> <td class="mobile-fold">third</td> </tr> </tbody> </table> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM