可能Pathing的問題
一個使用背景圖片這種方式是,你需要確保路徑是正確的,因爲相對路徑將是從哪裏CSS聲明是由相對的問題。
如果您在實際的HTML文件中定義了此樣式,那麼您可能希望使用絕對URL(但是,如果您的網站易於移動,這可能是一種易碎的方法),以避免出現像這樣的:
/* You can use an absolute path to ensure that the proper file is always used */
background-image: url("http://www.yoursite.com/includes/images/achtergrond.png");
否則,如果你有這樣的風格在.css
文件中定義的,你可以肯定,這是相對於它的任何路徑將始終是一致的。只是確保從你的CSS文件圖像的相對路徑是正確的:
/* Your path may vary, but ensure that it is relative from your CSS file */
background-image: url("../../includes/images/achtergrond.png");
使用開發工具(F12)來解決
考慮使用內部開發人員工具(F12)的瀏覽器檢查有問題的元素(通過右鍵單擊>檢查元素)。這應該允許您查看background-image
屬性指向的確切位置,以驗證它是否正確。
其他風格問題
另外一個問題是,你需要確保元素,您正在使用的background-image
財產上實際支持,並會表現出來。請考慮使用樣式像那些在scaisEdge's response建議,以確保正確元素顯示圖像:
/* Adding these other styles may help the actual image "appear"
if this is not a pathing issue */
.hoofd {
background: url("{your-path-here}")
background-size: cover;
background-repeat: no-repeat;
height: 100%;
width: auto;
display: block;
}
你確定你在元素中拼寫正確的類嗎? – Carcigenicate
請包括所有相關代碼,以便我們看到它如何使用 –
嘗試背景圖像。 http://www.w3schools.com/cssref/pr_background-image.asp 檢查類名稱是否正確 檢查圖像路徑網址是否正確 – NewUser