我自己的图像而不是从其他网站借来的图像的正确img src是什么? [英] What is the correct img src for an image that is my own and not borrowed from another website?

查看:101
本文介绍了我自己的图像而不是从其他网站借来的图像的正确img src是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的计算机上,保存我的.css和.html文件的文件夹还包含一些要插入html中的图像.我了解从其他网站借用图片的网址的方法.如何获取文件夹中但尚未在Internet上的图像的URL?我是否必须将图像上传到另一个网站上才能获得链接?

On my computer, the folder that holds my .css and .html file also contains some images that I want to insert in my html. I understand how to get a url for an image if I borrow it from another website. How do I acquire a url for an image that is in my folder, but not yet on the internet? Do I have to upload the image on another website in order to get a link?

我还了解到,我应该使用头部的base标签为html中的相对URL提供链接,但是在此阶段,我没有包含图像的链接.

I also understand that I should use the base tag in the head to provide a link for my relative urls in the html but at this stage, I don't have a link that contains the images.

推荐答案

假设您的网页(.html)位于C:\Project\index.html.

Assume your web page(.html) located in C:\Project\index.html.

您可以将图像放置在与网页相同的路径中,并将其与相对路径一起使用:

You can place your image in the same path with the web page, and use it with relative path:

<img src="img.jpg"/>

或者,如果它在其他路径中,则更像您的Web根目录的某些子文件夹:C:\Project\images:

Or if it's in other path, more like some sub folder of your web root: C:\Project\images:

<img src="/images/img.jpg"/>

如果图像文件位于index.html的父文件夹中,请使用该文件:

If image file is located in the parent folder of your index.html, use that:

<img src="../img.jpg"/>

最后一种用法是使用绝对路径,不建议这样做:

The last useage is to use the absolute path, which is not recommended:

<img src="C:/Project/images/img.jpg"/>

这篇关于我自己的图像而不是从其他网站借来的图像的正确img src是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆