My innovative approach involves just two additional CSS declarations to solve the issue at hand. The key is setting a max-width for the tab, although there could be complications if the number of tabs changes dynamically.
* {
box-sizing: border-box;
}
div.tab {
max-width: calc(20% - 3.2px);
}
Given that there are five tabs in total, each one should ideally occupy a maximum width of 20%. However, factoring in the gaps becomes crucial. With four spaces between tabs, each measuring 4px, this totals to 16px. Dividing this by the number of tabs and subtracting it from the original 20% value provides the desired result.
* {
box-sizing: border-box;
}
div.table-container, div.flex-container {
min-width: 100%;
padding-bottom: 32px;
}
table {
border-collapse: collapse;
}
td.left, td.right {
min-width: 8px;
width: 32px;
}
td {
border-top: 1px solid black;
}
td.left {
border-left: 1px solid black;
}
td.content {
white-space: nowrap;
}
td.right {
border-right: 1px solid black;
}
td.space {
border-top: none;
width: 4px;
}
div.flex {
display: flex;
gap: 4px;
}
div.tab {
border: 1px solid black;
border-bottom: none;
display: flex;
max-width: calc(20% - 3.2px);
}
div.left, div.right {
display: inline-block;
min-width: 8px;
width: 32px;
}
div.content {
white-space: nowrap;
}
<div class="table-container">
<table>
<tr>
<td class="left"></td>
<td class="content">Tab QWERTY</td>
<td class="right"></td>
<td class="space"></td>
<td class="left"></td>
<td class="content">Tab ABCDEF</td>
<td class="right"></td>
<td class="space"></td>
<td class="left"></td>
<td class="content">Tab ZXCVBB</td>
<td class="right"></td>
<td class="space"></td>
<td class="left"></td>
<td class="content">Tab POIUYT</td>
<td class="right"></td>
<td class="space"></td>
<td class="left"></td>
<td class="content">Tab LKJHGF</td>
<td class="right"></td>
</tr>
</table>
</div>
<div class="flex-container">
<div class="flex">
<div class="tab">
<div class="left"></div>
<div class="content">Tab QWERTY</div>
<div class="right"></div>
</div>
<div class="tab">
<div class="left"></div>
<div class="content">Tab ABCDEF</div>
<div class="right"></div>
</div>
<div class="tab">
<div class="left"></div>
<div class="content">Tab ZXCVBB</div>
<div class="right"></div>
</div>
<div class="tab">
<div class="left"></div>
<div class="content">Tab POIUYT</div>
<div class="right"></div>
</div>
<div class="tab">
<div class="left"></div>
<div class="content">Tab LKJHGF</div>
<div class="right"></div>
</div>
</div>
</div>