2013-08-26 77 views
0

我目前正在忙於創建一個簡單的網站。background-image no display

當我試圖創建一個背景圖像,它不會顯示。我使用相同的映射只是一個正常的圖像,只是爲了檢查我的映射是否沒有錯。

這是我當前的代碼:

<body> 
<table> 
<!-- multiple <trs><tds><divs></divs></tds></trs> --> 
</table> 
</body> 

我的CSS是這樣的:

* { 
    padding:0; margin:0; 
} 

html, body { 
    height:100%; 
    width: 100%; 
} 

body{ 
    background: transparent url('./img/background.jpg') no-repeat 0 center; 
    display: inline-block; 
} 

編輯:

我把它改爲:

background: transparent url('../img/background.jpg') no-repeat 0 center; 

它的工作,但是當我刷新了Ë頁面再次,它採空工作..

+1

'body {display:inline-block;}'?真的嗎? –

+0

@ Mr.Alien我將這個問題搜索了大約30分鐘,幾乎每個線程都告訴有這個問題的人使用display:block;或顯示:inline-block;要解決這個問題。以防萬一,我只是沒有刪除它。 – nlreturns

+0

不要使用它,'body'默認是塊級元素,不要使它成爲'inline-block' –

回答

0
Change this code 

background: transparent url('./img/background.jpg') no-repeat 0 center; 

and write like this 

background: transparent url('../img/background.jpg') no-repeat 0 center; 
0

試試這個:

background-image: transparent url('../img/background.jpg') no-repeat 0 center; 
+0

這是什麼魔法?這對我來說並不合適。它不在早期的位置,我甚至嘗試過!但是,感謝它現在的作品..奇怪。 – nlreturns

+0

@JanwillemDooms很好,如果它的工作現在.. –

+0

好..奇怪的是,當我再次刷新頁面,背景已經消失..代碼保持不變。 CSS對於程序員來說確實是一個令人矚目的故事。 – nlreturns

0

./需要更改到別的../它不會工作

0

無論是../img/background.jpgimg/background.jpg更換./img/background.jpg'