Unfortunately, you need to add a row wrapper around each set of columns without using another layout method (e.g. flexbox).
Since you already have the Flexbox answer (see @Shiva answer), here's a table with row wrappers and table-layout: fixed; . Note. I also changed your ul and li to a div to remove some automatic CSS that applies to list items.
.table { display: table; border-collapse: separate; border-spacing: 30px 30px; width: 100%; table-layout: fixed; } .row { display:table-row;width: 100%; } .cell { display:table-cell; padding:5px; background-color: gold; width: 33.33%; text-align: center; }
<div class="table"> <div class="row"> <div class="cell">Cell 1</div> <div class="cell">Cell 2</div> <div class="cell">Cell 3</div> </div> <div class="row"> <div class="cell">Cell 4</div> <div class="cell">Cell 5</div> <div class="cell">Cell 6</div> </div> </div>
Updated:
I still think you should consider a different layout method (e.g. flexbox), but if you want to use a CSS table layout with variable-width cells, you can actually use table instead of emulating one, and using the colspan attribute. Please note that this is a very old school and can hardly be considered useful for the actual layout. If you show tabular data, thatโs fine, but if you post more complex content, look at the flash block (the answer is provided, which should work for you), or a CSS grid, or grids like Ungrid .
Regardless, here is the table:
table { border-collapse: separate; border-spacing: 30px 30px; width: 100%; table-layout: fixed; } td { padding:5px; background-color: gold; text-align: center; }
<table> <tbody> <tr> <td>Cell 1</td> <td>Cell 2</td> <td>Cell 3</td> </tr> <tr> <td colspan="3">Cell 4</td> </tr> </tbody> </table>
source share