2011-12-21 78 views
0

我做了一個簡單的HTML頁面,其上顯示圖像作爲標題。問題是圖像不重複。背景重複不起作用

當我將width設置爲100%時,td(side)消失。 如果我從basestrip刪除width,那麼它只覆蓋屏幕區域的一半。我想要覆蓋具有指定高度的圖像的所有屏幕。

<table cellpadding="0" cellspacing="0"> 
    <tr> 
     <td id="side" width="10px" height="25px"></td> 
     <td></td> 
     <td id="basestrip" width="100%" height="25px"> 
        </td> 
      </tr> 
</table> 

這是CSS:

#side { 
background-color: #014160; 
} 

#basestrip { 
    background-image: url('../Images/topstripbg.png'); 
    background-repeat: repeat-x;  
} 
+0

財產你嘗試過將背景圖像到'tr'元素,而不是'td'? – Aaron 2011-12-21 06:11:44

+0

你在佈置一個使用表格的網站?另外,給#basetrip寬度爲90%,#寬度爲8%,看看側面是否停留。 – Indranil 2011-12-21 06:13:55

+1

也檢查圖像路徑是否正確,可能是它沒有加載圖像.. – 2011-12-21 06:18:24

回答

0

嘗試添加寬度=「100%」(或更好的風格=「寬度:100%」,甚至更好地運用寬的CSS樣式:100%)你的桌子。通過你的代碼,單元格佔用了100%的表格。但該表默認採用所有單元格的內容大小。

+0

我所做的是...給表中的100%,並在tr中設置圖像,然後休息我已經應用了CSS。 – 2011-12-21 08:53:50

0

首先,該元件不具有高度特性,可應用於。你也不能將'px'附加到html標籤的高度或寬度屬性上,這隻適用於CSS。我認爲這個表格應該是瀏覽器窗口的寬度,高25像素,1行3格,第一個寬10px,第二個你沒有指定,最後一個你有100%。這裏是我的跨瀏覽器的方法:

<html> 
    <head> 
    <style type="text/css"> 
     #thetable { width:100%; height:25px; } 
     #thetable>tr { height: 25px } 
     #thetable>tr>td#side { width: 10px } 
     #thetable>tr>td#basestrip { background: url('../Images/topstripbg.png') repeat-x; } 
    </style> 
    </head> 

    <body> 
    <table id="thetable" width="100%" cellpadding="0" cellspacing="0"> 
     <tr> 
     <td id="side" width="10"></td> 
     <td width="auto"></td> 
     <td id="basestrip" width="100%"></td> 
     </tr> 
    </table> 
    </body> 
</html> 
0

採取這樣

#basestrip { background: url('../Images/topstripbg.png') repeat-x; }