2012-01-21 43 views
2

我有一個表的代碼,我有三個單元格。我希望每個單元具有不同的背景圖像。但問題是,只有第一個單元顯示圖像!請幫忙!我的代碼:<TD>單元格不顯示背景圖像

我改變了#topbar td的寬度!

成功的代碼:

#topbar { 
     width: 100%; 
     color: transparent; 
     font-size: 13px; 
     border-spacing: 0px; 
     white-space: nowrap; 
    } 
    #topbar td { 
     width: 8.33333%; 
     margin: 0px; 
     padding: 0px; 
    } 
    #topbar td { 
     height: 15px; 
     margin: 0px; 
     background-color: transparent; 
     white-space: nowrap; 
     cursor: pointer; 
    } 
    #topbar td:hover { 
     background-color: transparent; 
    } 
    #topbar td.selected { 
     font-weight: bold; 
     color: #FFFFF; 
    } 
    #topbar td.empty { 
     cursor: auto; 
    } 
    #topbar td.empty:hover { 
     background-color: #2d2d2d; 
    } 
    #topbar td span { 
     display: image; 
    } 

OLD CODE 在頭

#topbar { 
    width: 100%; 
    color: transparent; 
    font-size: 13px; 
    border-spacing: 0px; 
    white-space: nowrap; 
} 
#topbar td { 
    width: 100%; 
    margin: 0px; 
    padding: 0px; 
} 
#topbar td { 
    height: 15px; 
    margin: 0px; 
    background-color: transparent; 
    white-space: nowrap; 
    cursor: pointer; 
} 
#topbar td:hover { 
    background-color: transparent; 
} 
#topbar td.selected { 
    font-weight: bold; 
    color: #FFFFF; 
} 
#topbar td.empty { 
    cursor: auto; 
} 
#topbar td.empty:hover { 
    background-color: #2d2d2d; 
} 
#topbar td span { 
    display: image; 
} 

在機身:

<table id="topbar"> 
    <tr> 
     <td class="box2d" style="background: url(http://osxcrash.webs.com/MacBarMain.PNG) no-repeat"> 
     <td class="box2d" style="background: url(http://osxcrash.webs.com/MacBar.PNG) no-repeat"> 
     <td class="box2d" style="background: url(http://osxcrash.webs.com/MacBar2.png) no-repeat"> 
    </tr> 
</table> 
+0

確保文件名是小寫的,也告訴你什麼是鏈接 – Grumpy

+2

是無效的HTML - 你不關閉表格單元 –

+1

'display:image;'不是CSS。 @Pekka'td'的結束標記在HTML中是可選的。 – fuxia

回答

2

圖像全部顯示在一起,因此您只能看到第一個圖像。

不知道你怎麼想他們展示,但增加display:block;#topbar td規則將阻止他們在彼此

編輯的頂部:如果你想向他們展示你需要指定在同一行每個TD元素的寬度值。目前設定的100%的值是佔用了全屏幕,以便掩蓋其他的TD元素

例中的觀點:http://jsfiddle.net/mZEWN/

+0

是寬度:100%是源問題。 – ogur

+0

我懂了!生病編輯我的代碼與正確的一個! – PrplNinja

0

嘗試關閉您的TD應答器:

<table id="topbar"> 
    <tr> 
     <td class="box2d" style="background: url(http://osxcrash.webs.com/MacBarMain.PNG) no-repeat"/> 
     <td class="box2d" style="background: url(http://osxcrash.webs.com/MacBar.PNG) no-repeat"/> 
     <td class="box2d" style="background: url(http://osxcrash.webs.com/MacBar2.png) no-repeat" /> 
    </tr> 
</table> 
+2

'​​'標籤不能像這樣自我關閉 – ChrisW