2012-07-24 250 views
0

我是新來的CSS,當我試圖插入background-image它不會顯示。CSS background-image not showing

HTML:

<div id="logo"></div> 

CSS:

#logo { 
    background-image: url(../images/logo.png); 
    background-repeat: no-repeat; 
    width: 376px; 
    height: 81px; 
    margin-top: 28px; 
    margin-left: 128px; 
} 
+3

在船尾添加分號請確保此圖像路徑正確 – bugwheels94 2012-07-24 11:36:06

+0

使用Chrome檢查器打開您的頁面,然後單擊圖像網址以檢查它的工作原理。 – 2012-07-24 11:40:13

+0

確保你的圖片路徑是正確的,正如其他人所說,請在你的寬度和高度屬性後添加分號。 – 2012-07-24 11:41:46

回答

6

您高度&寬度

#logo { 
    background-image: url("../images/logo.png"); 
    background-repeat: no-repeat; 
    width: 376px; 
    height: 81px; 
    margin-top: 28px; 
    margin-left: 128px; 
} 
後需要在URL路徑周圍的報價和分號
+4

url的引號是可選的。 – 2012-07-24 11:38:32

+0

好的 - 我從來不知道它們是可選的 - 有用 – BonyT 2012-07-24 11:39:21

+0

這沒有必要(引號)。 – F0G 2012-07-24 11:40:20