2016-05-10 43 views
0

我希望我的第3排在外觀上看起來像第1排。最初我試圖給rowspan =「1.5」,因爲它努力工作,我試着用上面的代碼。當我嘗試按照我在跟蹤第一行時導致錯位的程序時。是否可以在HTML表中使用rowspan作爲1.5?

table { 
 
    border-collapse: collapse; 
 
    border: 0px; 
 
} 
 
td { 
 
    padding: 20px; 
 
    border: 1px solid black; 
 
    text-align: center; 
 
} 
 
thead tr th { 
 
    border: 0px; 
 
}
<table border="1" width="100%"> 
 
    <thead style="border: 0px solid black;"> 
 
    <tr style="border=" 0px "> 
 
     <th style="border: 0px ">Row 1</th> 
 
     <th style="border: 0px ">Row 2</th> 
 
     <th style="border: 0px ">Row 3</th> 
 
    </tr> 
 
    </thead> 
 
    <tr> 
 
     <td rowspan="2 ">Row 1, cell 1</td> 
 
     <td rowspan="3 ">Row 1, cell 2</td> 
 
     <td >Row 1, cell 3</td> 
 
    </tr> 
 
    <tr>  
 
     <td>Row 2, cell 3</td> 
 
    </tr> 
 
    <tr> 
 
     <td rowspan="2 ">Row 3, cell 1</td> 
 
     <td rowspan=" ">Row 3, cell 3</td> 
 
    </tr> 
 
    <tr>  
 
     <td rowspan="3 ">Row 4, cell 2</td> 
 
     <td>Row 4, cell 3</td> 
 
    </tr> 
 
    <tr> 
 
     <td rowspan="2 ">Row 5, cell 1</td> 
 
     <td>Row 5, cell 3</td> 
 
    </tr> 
 
    <tr> 
 
     <td>Row 6, cell 3</td> 
 
    </tr> 
 
</table>

+2

這究竟是你想要的?至少我有點困惑。 – thepio

+1

這裏是你的問題的小提琴:https://jsfiddle.net/2ejpx1dd/。請解釋你想要的。 – thepio

+0

列是行還是行是列? – LAL

回答

2

你不能與HTML表格rowspan的浮動值。

根據W3:

rowspan:這個屬性指定由 當前小區跨越的行數。該屬性的默認值是1(「1」)。 值零(「0」)是指該細胞跨越從 當前行中的所有行的表部分的最後一行(THEAD,TBODY,或 TFOOT),其中小區被定義

編輯: 當您使用<td rowspan="x">必須刪除下一<tr>

對應這是否適合你x時間?

<table> 
    <tr> 
    <td rowspan="2">r1 c1</td> 
    <td rowspan="3">r1 c2</td> 
    <td rowspan="2">r1 c3</td> 
    </tr> 
    <tr> 
    </tr> 
    <tr> 
    <td rowspan="2">r2 c1</td> 
    <td rowspan="2">r2 c3</td> 
    </tr> 
    <tr> 
    <td rowspan="3">r2 c2</td> 
    </tr> 
    <tr> 
    <td rowspan="2">r3 c1</td> 
    <td rowspan="2">r3 c3</td> 
    </tr> 
</table> 
相關問題