Tables

border-collapse

用於控制表格邊框應該合併還是分離的通用類別。

ClassStyles
border-collapse
border-collapse: collapse;
border-separate
border-collapse: separate;

範例(Examples)

合併表格邊框(Collapsing table borders)

使用 border-collapse 通用類別在可能的情況下將相鄰儲存格的邊框合併為單一邊框:

StateCity
IndianaIndianapolis
OhioColumbus
MichiganDetroit
<table class="border-collapse border border-gray-400 ...">  <thead>    <tr>      <th class="border border-gray-300 ...">State</th>      <th class="border border-gray-300 ...">City</th>    </tr>  </thead>  <tbody>    <tr>      <td class="border border-gray-300 ...">Indiana</td>      <td class="border border-gray-300 ...">Indianapolis</td>    </tr>    <tr>      <td class="border border-gray-300 ...">Ohio</td>      <td class="border border-gray-300 ...">Columbus</td>    </tr>    <tr>      <td class="border border-gray-300 ...">Michigan</td>      <td class="border border-gray-300 ...">Detroit</td>    </tr>  </tbody></table>

請注意,這包括合併頂層 <table> 標籤上的邊框。

分離表格邊框(Separating table borders)

使用 border-separate 通用類別來強制每個儲存格顯示其獨立的邊框:

StateCity
IndianaIndianapolis
OhioColumbus
MichiganDetroit
<table class="border-separate border border-gray-400 ...">  <thead>    <tr>      <th class="border border-gray-300 ...">State</th>      <th class="border border-gray-300 ...">City</th>    </tr>  </thead>  <tbody>    <tr>      <td class="border border-gray-300 ...">Indiana</td>      <td class="border border-gray-300 ...">Indianapolis</td>    </tr>    <tr>      <td class="border border-gray-300 ...">Ohio</td>      <td class="border border-gray-300 ...">Columbus</td>    </tr>    <tr>      <td class="border border-gray-300 ...">Michigan</td>      <td class="border border-gray-300 ...">Detroit</td>    </tr>  </tbody></table>

響應式設計(Responsive design)

border-collapse 通用類別前面加上像 md: 這樣的中斷點變體,讓該通用類別只在中型螢幕尺寸及以上時套用:

<table class="border-collapse md:border-separate ...">  <!-- ... --></table>

變體文件中了解更多關於使用變體的資訊。

Copyright © 2026 Tailwind Labs Inc.·商標政策(Brand)