- 前导斜杠告诉浏览器从根目录开始。
- 如果您没有前导斜杠,则表示您从当前目录引用。
- 如果在前导斜杠前添加两个点,则表示您正在引用当前目录的父目录。
采取以下文件夹结构
注意:
- ROOT 复选标记为绿色,
- 第二个复选标记是橙色,
- 第三个复选标记是紫色,
- 第四个复选标记是黄色
现在在index.html.en
文件中,您需要放置以下标记
<p>
<span>src="check_mark.png"</span>
<img src="check_mark.png" />
<span>I'm purple because I'm referenced from this current directory</span>
</p>
<p>
<span>src="/check_mark.png"</span>
<img src="/check_mark.png" />
<span>I'm green because I'm referenced from the ROOT directory</span>
</p>
<p>
<span>src="subfolder/check_mark.png"</span>
<img src="subfolder/check_mark.png" />
<span>I'm yellow because I'm referenced from the child of this current directory</span>
</p>
<p>
<span>src="/subfolder/check_mark.png"</span>
<img src="/subfolder/check_mark.png" />
<span>I'm orange because I'm referenced from the child of the ROOT directory</span>
</p>
<p>
<span>src="../subfolder/check_mark.png"</span>
<img src="../subfolder/check_mark.png" />
<span>I'm purple because I'm referenced from the parent of this current directory</span>
</p>
<p>
<span>src="subfolder/subfolder/check_mark.png"</span>
<img src="subfolder/subfolder/check_mark.png" />
<span>I'm [broken] because there is no subfolder two children down from this current directory</span>
</p>
<p>
<span>src="/subfolder/subfolder/check_mark.png"</span>
<img src="/subfolder/subfolder/check_mark.png" />
<span>I'm purple because I'm referenced two children down from the ROOT directory</span>
</p>
现在,如果您加载index.html.en
位于第二个子文件夹
http://example.com/subfolder/subfolder/中的文件
这将是你的输出