2、html表格
html在解析表格时,是作为一个整体来解析的,只有解析完之后才会显示出来,假设表格过于复杂,那么加载时间长,就会用户体验差,所以使用表格结构标签,来优化显示,加载一部分显示一部分,thead、tbody、tfoot。
thead:表格的头(放表格的表头)
tbody:表格的主体(放数据本体)
tfoot:表格的脚(放表格的脚注)
<table>
<caption>标题</caption>
<thead>
<tr>
<th>表头</th>
</tr>
</thead>
<tbody>
<tr>
<td>主体</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>脚注</td>
</tr>
</tfoot>
</table>
<table>
表格
<tr>
行
<td>
单元格
跨列属性:colspan (添加在td的属性中,在一行中占据两个格)
跨行属性:rowspan (添加在td的属性中,在一列中占据两个格)
<td cosplan="2">...</td>
<td rowspan="2">...</td>
表格嵌套:只能嵌套在td中,并且嵌套的表格必须时完整的表格结构
<table border="" cellspacing="" cellpadding="">
<tr>
<td>Data</td>
<td>
<table border="" cellspacing="" cellpadding="">
<tr><th>Header</th></tr>
<tr><td>Data</td></tr>
</table>
</td>
</tr>
</table>
垂直对齐:valign