2012-02-05 33 views
2

我想跨越2錶行的背景圖像,但這似乎並沒有工作。如何將圖像跨越2個表格行?

HTML:

<table id="branchTable"> 
<thead> 
    <th align="center">Tel.</th> 
    <th align="center">Fax</th> 
    <td rowspan="2" id="branch-logo"> d</td> 
</thead> 
<tbody> 
    <td align="center">${_branch?.tel}</td> 
    <td align="center">${_branch?.fax}</td> 
</tbody> 
</table> 

CSS:

#branch-logo { 
    background-image: url(/public/images/logo.png); 
    height:53px; 
    width:100px; 
    background-repeat: no-repeat; 
    background-position: left; 
} 

的形象似乎被向下推動該行並沒有跨越翻過。

UPDATE

<table id="branchTable"> 
<tr id="thead"> 
    <th align="center">Tel.</th> 
    <th align="center">Fax</th> 
    <td rowspan="2" id="branch-logo"> d</td> 
</tr> 
<tr id="tbody"> 
    <td align="center">${_branch?.tel}</td> 
    <td align="center">${_branch?.fax}</td> 
</tr> 
</table> 

行跨度似乎並不TBODY和THEAD之間的合作。使用tr是個訣竅。

+1

我在您張貼的HTML中的任何地方都看不到'#branch-logo'。你的桌子有一排。事實上,由於格式錯誤的HTML,它確實沒有任何行。 – Scott 2012-02-05 08:25:26

+0

很好的指針,愚蠢的錯誤... – emt14 2012-02-05 08:49:10

回答

3

您忘記了您的表<tr> s。這可能是導致它行爲不端的原因。

正如斯科特所說,你在你的html中使用logo,在你的CSS中使用branch-logo

編輯:另外,我並不確定所有主流瀏覽器是否支持在一個和一個tbody上跨越單元。這將需要一些測試。

+0

很好的感謝。 – emt14 2012-02-05 08:48:47