【問題描述】
當外層 table 與內層 table 相互嵌套,而內外表格都設定 border="1" 時,邊框會彼此重疊,導致某些位置線條看起來特別粗、某些位置又特別細,視覺上很不協調。
【解決辦法】
關鍵在於使用 border-collapse: collapse 讓相鄰邊框合併成一條線。
外層表格樣式:
<table border="1" cellspacing="0" cellpadding="0" style="border-collapse: collapse;">
內層表格樣式(額外把自身邊框隱藏,避免與外層重疊):
<table border="1" cellspacing="0" cellpadding="0"
style="border-collapse: collapse; border-width: 0px; border-style: hidden;">
以上就是關於表格嵌套邊框合並問題的解法,希望能給大家一個參考。