定義CSS表格樣式的方法如下:
1、定義表格整體樣式:
使用border
屬性定義表格的整體邊框,width
屬性定義邊框的寬度,style
屬性定義邊框的樣式。
table { border: 1px solid #000; }
2、定義表格行和列的樣式:
使用border-top
、border-right
、border-bottom
和border-left
屬性分別定義行和列的邊框。
table tr { border-top: 1px solid #000; border-bottom: 1px solid #000; } table td { border-right: 1px solid #000; border-left: 1px solid #000; }
3、定義表格單元格的樣式:
使用padding
屬性定義單元格的內(nèi)邊距,background-color
屬性定義單元格的背景顏色。
table td { padding: 10px; background-color: #fff; }
4、定義表格標(biāo)題的樣式:
使用font-size
和font-weight
屬性定義表格標(biāo)題的字體大小和粗細(xì)。
table th { font-size: 16px; font-weight: bold; }
5、定義表格行的樣式:
使用height
屬性定義表格行的高度。
table tr { height: 30px; }
版權(quán)聲明:除非特別標(biāo)注,否則均為本站原創(chuàng)文章,轉(zhuǎn)載時(shí)請(qǐng)以鏈接形式注明文章出處。