HTML表格跨行、跨列操作(rowspan、colspan)


轉自:https://blog.csdn.net/u012724595/article/details/79401401

一般使用<td>元素的colspan屬性來實現單元格跨列操作,使用<td>元素的rowspan屬性來實現單元格的跨行操作。

 

colspan屬性規定單元格可橫跨的列數,所有瀏覽器都支持colspan屬性。其取值為number,如下圖所示:

 

例如:

<table border="1">
<tr>
<th>星期一</th>
<th>星期二</th>
</tr>
<tr>
<td colspan="2">星期天</td>
</tr>
</table>
實現結果如下圖所示:

 

 

rowspan屬性規定單元格可橫跨的列數,所有瀏覽器都支持rowspan屬性。其取值為number,如下圖所示:

 

例如:

<table border="1">
<tr>
<td rowspan="2">星期一</td>
<td>星期二</td>
</tr>
<tr>
<td>星期三</td>
</tr>
</table>
實現結果如下圖所示:

 

 

總結colspan和rowspan的使用如下:

<table border="1">
<tr>
<th colspan="3">物資詳情說明</th>
</tr>
<tr>
<td colspan="2" align="center">數量(支)</td>
<td rowspan="2">重量(噸)</td>
</tr>
<tr>
<td>實發數</td>
<td>實收數</td>
</tr>
<tr>
<td>12</td>
<td>10</td>
<td>100.00</td>
</tr>
</table>
實現結果如下圖所示:


————————————————
版權聲明:本文為CSDN博主「sning999」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/u012724595/article/details/79401401


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



猜您在找 table合並單元格 colspan(跨列)和rowspan(跨行) table合並單元格 colspan(跨列)和rowspan(跨行) table中tr間距的設定table合並單元格 colspan(跨列)和rowspan(跨行) table中tr間距的設定table合並單元格 colspan(跨列)和rowspan(跨行) 【HTML】table表格拆分合並(colspan、rowspan) colspan="2"、列、rowspan="3"、行、用法! HTML的table的 rowspan, colspan 用法 latex制作表格-跨行跨列
 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM
標簽總結(colspan跨列 ,rowspan跨行) 七:HTML之表格跨行跨列