2012-03-03 13 views
0

我想使用background-image:url設置背景圖像,但它不工作。background-image:url不顯示圖像的背景使用css

<!doctype html> 
<html> 
    <head> 
     <title>MyTitle</title> 
     <style type="text/css"> 
      body{ 
       <!-- background-color:green; --> 
       background-image:url("background.jpg"); 
       <!-- color:white; --> 
       } 
     </style> 
    </head> 
    <body> 
    </body> 
</html> 

請幫助!!

+1

定義 「不工作」。檢查你的圖像是否在你想要的位置,以及你的路徑是否正確。使用當前路徑,您假定圖像與HTML文件位於同一目錄中。 – Bojangles 2012-03-03 17:34:17

回答

6
<!-- comment --> 

在CSS塊中是無效的註釋語法。這可能違反了你的CSS規則。

嘗試

/* comment */ 
3

標記不會窩入標籤。

嘗試

<!doctype html> 
<html> 
    <style type="text/css"> 
     body{ 
      /* background-color:green; */ 
      background-image:url("background.jpg"); 
      /* color:white; */ 
     } 
    </style> 
    <head> 
     <title>MyTitle</title> 
    </head> 
    <body> 
    </body> 
</html> 

而且在CSS的意見是這樣定義...

/*this is a comment*/