Split a table in half

匆匆过客 提交于 2019-12-10 12:34:30

问题


Is there anyway to split a table in half using CSS and display the two parts side-by-side.

For example, take this:

| row1 | row1 | row1 |
| row2 | row2 | row2 |
| row3 | row3 | row3 |
| row4 | row4 | row4 |
| row5 | row5 | row5 |

And make this:

| row1 | row1 | row1 |    | row4 | row4 | row4 |
| row2 | row2 | row2 |    | row5 | row5 | row5 |
| row3 | row3 | row3 |

I can change the HTML markup (like marking the "breaking" row with a custom class), but I have to be able decide if the table would be split or not via CSS.

I know that I could use two tables and use display:inline-table, but I must use just one table because of I need consistent column width (the table must have auto layout).


回答1:


you can use multi column, but it is a CSS3 property. eg:

-moz-column-count: 2;
-moz-column-gap: 20px;
-webkit-column-count: 2;
-webkit-column-gap: 20px;
column-count: 2;
column-gap: 20px;

This should work in the modern browsers

You can also try this method

http://www.csscripting.com/css-multi-column/



来源:https://stackoverflow.com/questions/6259675/split-a-table-in-half

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!