你不知道的table布局

Table 布局

概念

表格布局由两种实现方式:一种是HTML Table(<table>等相关标签和属性)和CSS Table(display:table等相关属性)。

元素 display选项 说明
table table/inline-table  
caption table-caption 表格标题
thead table-header-group  
tbody table-row-group  
tfoot table-footer-group  
tr table-row 表格行
th/td table-cell 单元格
colgroup table-column-group 单元列组
col table-column 单元列

知识点

HTML元素属性

table属性

  • cellpadding:单元格padding

CSS样式属性

table属性

  • table-layout: fixed/auto //默认auto,表示根据内容决定宽度;fixed表示根据首列宽度决定宽度
  • border-collapse:separate/collapse //默认separate,表示单元格边框和table边框分隔;collapse表示单元格边框和table边框合并

caption属性

  • caption-side//标题位置

其他

  • visibility:hidden 可以隐藏table的行和列

 

 

猜你喜欢

转载自blog.csdn.net/baidu_38798835/article/details/114382820