2011-12-22 43 views
0

我必須創建這張表,但是colspan和rowspan讓我的大腦變得瘋狂。請幫忙。如何使這個HTML表?

的jsfiddle空白實驗, - http://jsfiddle.net/3pbuT/2/ enter image description here

+0

Absolutelly感謝所有,你已經保存了我的屁股^ _^ – NiLL 2011-12-22 09:05:42

+0

你可能想看看一些基本的網站,如http://www.w3schools.com/html/或(如果你可以閱讀德語)http://de.selfhtml.org/ – 2011-12-22 09:30:35

+0

駝鹿,謝謝爲鏈接。 – NiLL 2011-12-22 09:35:57

回答

2

相當簡單.....你的混亂是你有多少行。該表中只有2行。

DEMO HERE

2
<table> 
<tr> 
    <td rowspan="2"></td> 
    <td rowspan="2"></td> 
    <td colspan="4"></td> 
    <td rowspan="2"></td> 
</tr> 
<tr> 
    <td></td> 
    <td></td> 
    <td></td> 
    <td></td> 
</tr> 

2

試試這個...如果你有Dreamweaver的工具,你可以做到這一點很容易....

<table width="200" border="1"> 
    <tr> 
    <td rowspan="2">&nbsp;</td> 
    <td rowspan="2">&nbsp;</td> 
    <td colspan="4">&nbsp;</td> 
    <td rowspan="2">&nbsp;</td> 
    </tr> 
    <tr> 
    <td>&nbsp;</td> 
    <td>&nbsp;</td> 
    <td>&nbsp;</td> 
    <td>&nbsp;</td> 
    </tr> 
</table> 
1
<html> 
    <head> 
    <style type='text/css'> 
     table { 
     border-spacing:0; 
     } 

     td { 
     border:1px solid grey; 
     } 
    </style> 
    </head> 
    <body> 
    <table> 
     <tr> 
     <td rowspan='2'>1 col, 2 rows</td> 
     <td rowspan='2'>1 col, 2 rows</td> 
     <td colspan='4'>4 col, 1 row</td> 
     <td rowspan='2'>1 col, 2 rows</td> 
     </tr> 
     <tr> 
     <td>1 col, 1 row</td> 
     <td>1 col, 1 row</td> 
     <td>1 col, 1 row</td> 
     <td>1 col, 1 row</td> 
     </tr> 
    </table> 
    </body> 
</html> 

編輯 - 我會推薦agai nst所見即所得的編輯,因爲你不會學習如何自己做。學習會讓你頭痛,但是你知道。給一個男人一條魚......

2

最簡單的方法是Dreamweaver的,但它並不需要很多的處理合並單元格和行跨度,我只是做這個用很少的思考,我用的jsfiddle公正,以確保它是正確的。

享受。

<table> 
<tr> 
<td rowspan="2"></td> 
<td rowspan="2"></td> 
<td colspan="4"></td> 
<td rowspan="2"></td> 
</tr> 
<tr> 
<td></td> 
<td></td> 
<td></td> 
<td></td> 
</tr> 
</table> 
2
<table> 
    <thead> 
     <tr> 
      <th rowspan="2">город 1</th> 
      <th rowspan="2">город 2</th> 
      <th colspan="4">город 3</th> 
      <th rowspan="2">город 4</th> 
     </tr> 
     <tr> 
      <th>город 5</th> 
      <th>город 6</th> 
      <th>город 7</th> 
      <th>город 8</th> 
     </tr> 
    </thead> 
</table> 
2

事情是這樣的:

<table> 
    <tr> 
     <td rowspan="2">&nbsp;</td> 
     <td rowspan="2">&nbsp;</td> 
     <td colspan="4">&nbsp;</td> 
     <td rowspan="2">&nbsp;</td> 
    </tr> 
    <tr> 
     <td>&nbsp;</td> 
     <td>&nbsp;</td> 
     <td>&nbsp;</td> 
     <td>&nbsp;</td> 
    </tr> 
</table> 

http://jsfiddle.net/3pbuT/9/

2
<html> 
<head> 
</head> 
<body> 
    <table border="1"> 
     <tr> 
      <td rowspan="2">one</td> 
      <td rowspan="2">Two</td> 
      <td colspan="4">Im big!</td> 
      <td rowspan="2">Last</td> 
     </tr> 
     <tr> 
      <td rowspan="2">one</td> 
      <td rowspan="2">Two</td> 
      <td>Part 1</td> 
      <td>Part 2</td> 
     </tr> 
    </table> 
</body> 
</html> 
2

在這裏,你去..

<table border="1"> 
<tr> 
    <td rowspan="2"></td> 
    <td rowspan="2"></td> 
    <td colspan="4"></td> 
    <td rowspan="2"></td> 
</tr> 
<tr> 
    <td></td> 
    <td></td> 
    <td></td> 
    <td></td> 
</tr> 
</table> 
2

合作lspan結合了列,rowspan結合了行。所以你看最多有多少行,最多有多少列。

你的情況,你有最多7列和2行最大:

<table border="1"> 
    <tr> 
     <td>a</td> 
     <td>b</td> 
     <td>c</td> 
     <td>d</td> 
     <td>e</td> 
     <td>f</td> 
     <td>g</td> 
    </tr> 
    <tr> 
     <td>h</td> 
     <td>i</td> 
     <td>j</td> 
     <td>k</td> 
     <td>l</td> 
     <td>m</td> 
     <td>n</td> 
    </tr> 
</table> 

然後你把列/行:

<table border="1" style="padding:5px;border-spacing:10px"> 
    <tr> 
     <td rowspan="2">a (former a)</td> 
     <td rowspan="2">b (former b)</td> 
     <td colspan="4">c (former c)</td> 
     <td rowspan="2">d (former g)</td> 
    </tr> 
    <tr> 
     <td>e</td> 
     <td>f</td> 
     <td>g</td> 
     <td>h</td> 
    </tr> 
</table>