简体   繁体   English

如何在 HTML 中包含来自另一个驱动器的图片?

[英]How to include a picture in HTML from another drive?

I am learning HTML, CSS and javascript in preparation for my school project involving frontend development.我正在学习 HTML、CSS 和 javascript,为我的学校项目做前端开发做准备。 Here's the question.这是问题。

When I was trying to insert a picture in one of my HTML file.当我试图在我的 HTML 文件之一中插入图片时。 The picture is located in drive C: and the HTML file is located in drive E:.I used a <image> tag.图片位于驱动器 C: 中,HTML 文件位于驱动器 E: 中。我使用了<image>标签。

practice.html: E:\Frontend-Notes\Mainpage\practice.html practice.html: E:\Frontend-Notes\Mainpage\practice.html
10-11.jpg: C:\Users\wangz\Pictures\WallPaper\Scenery\10-11.jpg 10-11.jpg: C:\Users\wangz\Pictures\WallPaper\Scenery\10-11.jpg

   <image src = "C:\Users\wangz\Pictures\WallPaper\Scenery\10-11.jpg">

Then I ctrl+click-ed the path which is supposed to be an absolute path, VS code showed an error message below.然后我 ctrl+click-ed 应该是绝对路径的路径,VS 代码在下面显示了一条错误消息。 error message错误信息

I don't know how to deal with it.我不知道如何处理它。

So, you can solve your problem by two ways-- 1.) Cut and paste your 10-11.jpg file in your project folder, ie, E:\Frontend-Notes\Mainpage因此,您可以通过两种方式解决您的问题-- 1.) 将您的 10-11.jpg 文件剪切并粘贴到您的项目文件夹中,即E:\Frontend-Notes\Mainpage

2.) You need to put the address in src as given below -- file:///C:\Users\wangz\Pictures\WallPaper\Scenery\10-11.jpg 2.) 您需要将地址放入 src 中,如下所示 -- file:///C:\Users\wangz\Pictures\WallPaper\Scenery\10-11.jpg

Maybe it helps you.也许它可以帮助你。

A quick fix is to move the image you want to use to the same directory with your project, or within your project directory create a folder for the images you'll be using.一个快速的解决方法是将您要使用的图像移动到与您的项目相同的目录中,或者在您的项目目录中为您将使用的图像创建一个文件夹。 This is not only a good practice but also a more suitable way to keep your project files organised.这不仅是一种很好的做法,而且是一种更适合组织项目文件的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM