ced*_*d-b 5 html javascript css firefox multiple-columns
这个问题似乎主要适用于 Firefox。我使用以下 CSS 样式在 HTML 中有两列布局:
div.column-container {
-webkit-column-count: 2;
-webkit-column-gap: 10px;
-moz-column-count: 2;
-moz-column-gap: 10px;
column-count: 2;
column-gap: 10px;
}
Run Code Online (Sandbox Code Playgroud)
这对于文本和一般内容非常有用,但我有一个大表,我想将其拆分为两列,并且现在看来,该表只是进入一列或另一列。
我尝试了各种方法,例如
div.column-container tr {
page-break-after: auto;
page-break-before: auto;
}
Run Code Online (Sandbox Code Playgroud)
但这似乎没有帮助。
这是说明情况的小提琴:http://jsfiddle.net/hq2uukm5/1/
有谁知道如何将一个表分成多个列?
我尝试了一些随机的想法,但无法在 Firefox 中实现任何功能。
我唯一想到的就是修复隐藏在第二列上的顶部边框,并修复镀铬中列之间的大间隙。
div.column-container { display: inline-block; }
tr:nth-child(33) td {
border-width: 2px 1px 1px 1px;
}
Run Code Online (Sandbox Code Playgroud)
因此,这不是问题的直接答案,而是对于那些不需要实际表格但想要表格样式布局的人的替代方法。
html
<div class="wrapper">
<div class="table">
<div class="tr"><div class="td">Test</div><div class="td">Test</div><div class="td">Test</div></div>
<div class="tr"><div class="td">Test</div><div class="td">Test</div><div class="td">Test</div></div>
<div class="tr"><div class="td">Test</div><div class="td">Test</div><div class="td">Test</div></div>
<div class="tr"><div class="td">Test</div><div class="td">Test</div><div class="td">Test</div></div>
</div><!-- end table -->
</div><!-- end wrapper -->
Run Code Online (Sandbox Code Playgroud)
CSS
.wrapper {
text-align: center; /* table needs a wrapper to center it */
}
.table {
display: inline-block; /* required to keep a nice spacing between columns */
-webkit-column-count: 2;
-webkit-column-gap: 10px;
-moz-column-count: 2;
-moz-column-gap: 10px;
column-count: 2;
column-gap: 10px;
}
.tr {
display: block;
}
.td {
display: inline-block;
border-width: 1px 0px 0px 1px;
border-style: solid;
border-color: #000000;
padding: 5px;
width: 50px;
text-align: center;
}
/* the following is to make borders even on all cells, something that tables do better than divs */
.td:last-child {
border-width: 1px 1px 0px 1px;
}
.tr:last-child {
border-width: 0px 0px 1px 0px;
border-style: solid;
border-color: #000000;
}
.tr:nth-child(6) {
border-width: 0px 0px 1px 0px;
border-style: solid;
border-color: #000000;
}
Run Code Online (Sandbox Code Playgroud)
小提琴
https://jsfiddle.net/Hastig/mmoh8kkd/
如果你的行数不断变化,那就需要一个小提琴(甚至没有边界)
https://jsfiddle.net/Hastig/jru2a5ta/
| 归档时间: |
|
| 查看次数: |
1415 次 |
| 最近记录: |