關於table這個tag
內嵌標籤: thead(可選)、tbody(可選)、td、tr、colgroup 、caption(可選)
屬性:align ,bgcolor ,bordercolor,border ,cellpadding ,cellspacing ,frame ,width ,summary ,rules 。
現在的table的屬性基本已經過時,都使用css進行設置table樣式。
關於table的css
1.border-collapse collapse | separate
collapse : border線合併
separate: border線分隔,默認屬性
ps: 使用collapse 此屬性時, border-spacing 、empty-cells和 border-radius 失效,無任何效果。
2.border-spacing horizontal < length > | vertical < length >
table {
border-collapse:separate;
border-spacing:0;
width:50%;
}
td { border:1px solid #000 }
/** tr hover設置td樣式 **/
table tr:hover td {
cursor: default;
background-color: #ccc;
border:1px solid red;
}
3.vertical-align 設置內容與圖片位置
4.table-layout auto | fixed
ps: auto 表格佈局自適應寬度
fixed 表格佈局固定寬度,文字內容等可能會溢出
5.caption-side 針對於caption標籤的css樣式設置
6.empty-cells 但單元格內無內容時候,可設置隱藏
參考:
https://www.sitepoint.com/community/t/table-format-using-css-border-issue/36882/3
https://css-tricks.com/almanac/properties/b/border-collapse/
https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Table