css column-count fails on html table in Firefox - Stack Overflow

The following code works on most browsers, but fails on Firefox, i.e. displays everything in one column

The following code works on most browsers, but fails on Firefox, i.e. displays everything in one column. What do I do?

The bottom of this post contains 2 screenshots. The first is my code in Chrome, the second in Firefox version 136.0.3 (64-bit). Both are being run on my Windows 11 Home laptop.

But I tested the code on Firefox on a Mac desktop and got the same problem there.

Someone suggested the solution in the following post:

Split table into css columns, issue in Firefox

That solution does not help. It breaks the structure of the table completely. The td's are no longer displayed in 2 columns within the table.

<div style="column-count:2; ">
  <table>
    <tbody>
      <tr><td>1 Street</td><td>Smith</td></tr>
      <tr><td>2 Street</td><td>Jones</td></tr>
      <tr><td>3 Street</td><td>Smith</td></tr>
      <tr><td>4 Street</td><td>Jones</td></tr>
      <tr><td>5 Street</td><td>Smith</td></tr>
      <tr><td>6 Street</td><td>Jones</td></tr>
      <tr><td>7 Street</td><td>Smith</td></tr>
      <tr><td>8 Street</td><td>Jones</td></tr>
      <tr><td>9 Street</td><td>Smith</td></tr>
      <tr><td>10 Street</td><td>Jones</td></tr>
      <tr><td>11 Street</td><td>Smith</td></tr>
      <tr><td>12 Street</td><td>Jones</td></tr>
      <tr><td>13 Street</td><td>Smith</td></tr>
      <tr><td>14 Street</td><td>Jones</td></tr>
      <tr><td>15 Street</td><td>Smith</td></tr>
      <tr><td>16 Street</td><td>Jones</td></tr>
      <tr><td>17 Street</td><td>Smith</td></tr>
      <tr><td>18 Street</td><td>Jones</td></tr>
      <tr><td>19 Street</td><td>Smith</td></tr>
      <tr><td>20 Street</td><td>Jones</td></tr>
      <tr><td>21 Street</td><td>Smith</td></tr>
      <tr><td>22 Street</td><td>Jones</td></tr>
      <tr><td>23 Street</td><td>Smith</td></tr>
    </tbody>
  </table>
</div>

The following code works on most browsers, but fails on Firefox, i.e. displays everything in one column. What do I do?

The bottom of this post contains 2 screenshots. The first is my code in Chrome, the second in Firefox version 136.0.3 (64-bit). Both are being run on my Windows 11 Home laptop.

But I tested the code on Firefox on a Mac desktop and got the same problem there.

Someone suggested the solution in the following post:

Split table into css columns, issue in Firefox

That solution does not help. It breaks the structure of the table completely. The td's are no longer displayed in 2 columns within the table.

<div style="column-count:2; ">
  <table>
    <tbody>
      <tr><td>1 Street</td><td>Smith</td></tr>
      <tr><td>2 Street</td><td>Jones</td></tr>
      <tr><td>3 Street</td><td>Smith</td></tr>
      <tr><td>4 Street</td><td>Jones</td></tr>
      <tr><td>5 Street</td><td>Smith</td></tr>
      <tr><td>6 Street</td><td>Jones</td></tr>
      <tr><td>7 Street</td><td>Smith</td></tr>
      <tr><td>8 Street</td><td>Jones</td></tr>
      <tr><td>9 Street</td><td>Smith</td></tr>
      <tr><td>10 Street</td><td>Jones</td></tr>
      <tr><td>11 Street</td><td>Smith</td></tr>
      <tr><td>12 Street</td><td>Jones</td></tr>
      <tr><td>13 Street</td><td>Smith</td></tr>
      <tr><td>14 Street</td><td>Jones</td></tr>
      <tr><td>15 Street</td><td>Smith</td></tr>
      <tr><td>16 Street</td><td>Jones</td></tr>
      <tr><td>17 Street</td><td>Smith</td></tr>
      <tr><td>18 Street</td><td>Jones</td></tr>
      <tr><td>19 Street</td><td>Smith</td></tr>
      <tr><td>20 Street</td><td>Jones</td></tr>
      <tr><td>21 Street</td><td>Smith</td></tr>
      <tr><td>22 Street</td><td>Jones</td></tr>
      <tr><td>23 Street</td><td>Smith</td></tr>
    </tbody>
  </table>
</div>

Share Improve this question edited Apr 2 at 17:29 Dharman 33.4k27 gold badges101 silver badges147 bronze badges asked Apr 1 at 5:19 oyveyoyvey 6071 gold badge9 silver badges20 bronze badges 4
  • This question is similar to: Split table into css columns, issue in Firefox. If you believe it’s different, please edit the question, make it clear how it’s different and/or how the answers on that question are not helpful for your problem. – tacoshy Commented Apr 1 at 5:49
  • 2 The CSSWG spec says that column-count applies to blocks, except tables. Chrome applies it to tables, but that goes beyond the spec. I'd suggest grid layout. – Nanigashi Commented Apr 1 at 6:12
  • The question is actually pretty much identical to mine, but the solution does not help, as explained in the Edit to my post. – oyvey Commented Apr 1 at 6:12
  • What's the purpose of the data you're presenting? It looks like it should/could be a list - in which case use a list, not a table - but that may just be the demo data from the question. – David Thomas Commented Apr 1 at 9:53
Add a comment  | 

1 Answer 1

Reset to default 1

The CSSWG spec says that column-count applies to blocks, except tables. Chrome applies it to tables, but that goes beyond the spec.

I'd suggest grid layout. However, then you have to specify "column" widths, too, otherwise you lose the table-like layout of columns.

table {
  column-count: 2;
  display: block;
}
tbody {
  display: grid;
}
td:first-child {
  min-width: 5em;
}
<table>
  <tbody>
    <tr><td>1 Street</td><td>Smith</td></tr>
    <tr><td>2 Street</td><td>Jones</td></tr>
    <tr><td>3 Street</td><td>Smith</td></tr>
    <tr><td>4 Street</td><td>Jones</td></tr>
    <tr><td>5 Street</td><td>Smith</td></tr>
    <tr><td>6 Street</td><td>Jones</td></tr>
    <tr><td>7 Street</td><td>Smith</td></tr>
    <tr><td>8 Street</td><td>Jones</td></tr>
    <tr><td>9 Street</td><td>Smith</td></tr>
    <tr><td>10 Street</td><td>Jones</td></tr>
    <tr><td>11 Street</td><td>Smith</td></tr>
    <tr><td>12 Street</td><td>Jones</td></tr>
    <tr><td>13 Street</td><td>Smith</td></tr>
    <tr><td>14 Street</td><td>Jones</td></tr>
    <tr><td>15 Street</td><td>Smith</td></tr>
    <tr><td>16 Street</td><td>Jones</td></tr>
    <tr><td>17 Street</td><td>Smith</td></tr>
    <tr><td>18 Street</td><td>Jones</td></tr>
    <tr><td>19 Street</td><td>Smith</td></tr>
    <tr><td>20 Street</td><td>Jones</td></tr>
    <tr><td>21 Street</td><td>Smith</td></tr>
    <tr><td>22 Street</td><td>Jones</td></tr>
    <tr><td>23 Street</td><td>Smith</td></tr>
  </tbody>
</table>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743907731a4527776.html

相关推荐

  • css column-count fails on html table in Firefox - Stack Overflow

    The following code works on most browsers, but fails on Firefox, i.e. displays everything in one column

    3天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信