【CSS】border-collapse 表格消除空隙

情況

table 預設的 style 方格與方格之間會有空隙
(在table, td, th都有設定border的情況下會很明顯)

解決:border-collapse

table
 tr
  th Items
  th Price
 tr
  td Apple
  td $10
 tr
  td Orange
  td $15
table, td, th 
 border: 1px solid black
 
table
 border-collapse: collapse

Display

沒有加border-collapse的情況

Items Price
Apple $10
Orange $15

有使用border-collapse的情況

Items Price
Apple $10
Orange $15

Leave a Reply

Your email address will not be published. Required fields are marked *