2017-06-18 45 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系统)上。