从子文件夹中选择根文件夹的图像 [英] Pick images of root folder from sub-folder
本文介绍了从子文件夹中选择根文件夹的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
让我们说以下是我的网站的目录结构:
Let's say following is the directory structure of my website :
现在在 index.html
中,我可以简单地引用以下图像:
Now in index.html
I can simply refer images like:
<img src="./images/logo.png">
但是我想引用 sub.html $中的同一张图片c $ c>。
src
应该是什么?
But I want to refer the same image from sub.html
. What should be the src
?
推荐答案
您可以使用相对路径:
<img src="../images/logo.png">
__ ______ ________
| | |
| | |___ 3. Get the file named "logo.png"
| |
| |___ 2. Go inside "images/" subdirectory
|
|
|____ 1. Go one level up
或者您可以使用绝对路径: /
表示这是服务器上的绝对路径,因此,如果您的服务器位于 https ://example.org/ ,从任何页面引用 /images/logo.png
都将指向 https://example.org/images/logo.png
Or you can use absolute path: /
means that this is an absolute path on the server, So if your server is at https://example.org/, referencing /images/logo.png
from any page would point to https://example.org/images/logo.png
<img src="/images/logo.png">
|______ ________
| | |
| | |___ 3. Get the file named "logo.png"
| |
| |___ 2. Go inside "images/" subdirectory
|
|
|____ 1. Go to the root folder
这篇关于从子文件夹中选择根文件夹的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文