2017-06-18 85 views
-1

enter image description here這是我的第一個HTML項目,在這裏iam試圖爲#nheader id放置背景圖片,但是當我切換鱈魚瀏覽器告訴我它無法加載我不知道原因?爲什麼我的標題背景圖像不起作用?

<html> 

<!--this is the 

start html file--> 
<head> 
    <meta keywords="html, laern, teach"/> 
    <link rel="stylesheet" type="text/css" href="style.css"> 
    <title> this is a website </title> 
</head> 

<body> 
    <div id="wrap"> 
    <div id="nheader"> 
     <h1>how to write html5</h1> 
     <img src="..my demo/images/body.jpg"> 
    </div> 
    <div id="npara"> 
     <p class="text_para"> 
     Lorem ipsum dolor sit amet, <span class="color">consectetur</span> adipisicing elit, sed do eiusmod 
     tempor incididunt ut labore et dolore magna aliqua. Ut enim ad 
     </p> 
     </div> 

     <div id="footer"> 
     <p class="text_para"> 
     this is footer 
     </p> 
     </div> 

    </div> 


</body> 

<!--here ends th html file --> 
</html> 
+0

'..my demo/images/body.jpg'不是一個有效的路徑,應該是'../my demo/images/body.jpg',但這取決於你的設置。同時避免在路徑中使用空格 – moritzg

+0

一個閃亮的例子,爲什麼HTML和CSS驗證器在每個網頁創建中扮演重要角色。 – Rob

+0

感謝親愛的,羅布您的評論, 我已經改變了路徑,因爲你告訴我上面,但它是同樣的問題 –

回答

1

您的圖片不能正常工作,因爲它的路徑是不正確。路徑可以是:

  • 絕對路徑(它們不論工作的它們是從稱爲哪裏)http://example.com/images/body.jpg
  • 相對路徑
    • 到當前腳本:(即./images/body.jpg../../images/body.jpg
    • 到當前域/機器:(即/images/body.jpg,~/img/logo-free.png

有關路徑如何在不同系統上工作的更多信息,請考慮閱讀Wiki:Path (computing)

請記住,任何服務器(域)實際上託管在一臺機器(計算機)上,因此,其文件夾結構可通過其路徑系統訪問(有關Web的限制)。

絕大多數Web域都託管在Linux(Unix shell系統)上。