如何将超链接放到“目录树中的两个级别”?

时间:2022-05-10 11:17:50

I am trying to code my Home button. Is there a way to just climb back up the file structure, instead of using the absolute path like I have below.

我正在尝试编写我的主页按钮。有没有办法只是爬回文件结构,而不是像我下面那样使用绝对路径。

I have a file index.html that I have at C:\Users\Randy\Documents\XML\

我有一个文件index.html,我在C:\ Users \ Randy \ Documents \ XML \

Heres my code:

继承我的代码:

<a id="my-family" href="C:\Users\Randy\Documents\XML\index.html">Home</a> 

Heres where I am trying to come from: C:\Users\Randy\Documents\XML\project\xml

我试图来自哪里:C:\ Users \ Randy \ Documents \ XML \ project \ xml

5 个解决方案

#1


15  

You can use ../index.html to refer to index.html in the parent directory.

您可以使用../index.html来引用父目录中的index.html。

#2


14  

to go two level up use "../../" and your normal url from two level up folder.

升级两级使用“../../”和两个级别文件夹中的普通网址。

"../" in the path is used to go one level up. But, it can be used for more times, to go more levels up.

路径中的“../”用于向上一级。但是,它可以使用更多次,更高层次。

an example:

一个例子:

| HOME <br> 
+- image.jpg<br> 
|_
  |
  +- CONFIG<br>  
     |
     + PICTURE_CONFIG
       | 
       +- myfile.html

myfile.html contains:

myfile.html包含:

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

the second"../" goes from PICTURE_CONFIG to CONFIG folder
the first "../"goes from CONFIG to HOME folder
"image.jpg" searches in HOME folder for the file "image.jpg"

第二个“../”从PICTURE_CONFIG到CONFIG文件夹第一个“../"从CONFIG到HOME文件夹”image.jpg“在HOME文件夹中搜索文件”image.jpg“

#3


2  

I'm not sure exactly what you're asking, but in relative paths, ../ is 'up one level'.

我不确定你究竟在问什么,但在相对路径上,../是'上升一级'。

So, ../index.html would take you to the index of the next directory up. Hope that helps.

所以,.. / index.html会带你到下一个目录的索引。希望有所帮助。

#4


1  

  1. <img src="picture.jpg"> WHEN picture.jpg is located in the same folder as the current page

    如何将超链接放到“目录树中的两个级别”? WHEN picture.jpg与当前页面位于同一文件夹中

  2. <img src="images/picture.jpg"> WHEN picture.jpg is located in the images folder located in the current folder

    如何将超链接放到“目录树中的两个级别”? WHEN picture.jpg位于当前文件夹中的images文件夹中

  3. <img src="/images/picture.jpg"> WHEN picture.jpg is located in the images folder located at the root of the current web

    如何将超链接放到“目录树中的两个级别”? WHEN picture.jpg位于当前网站根目录的images文件夹中

  4. <img src="../picture.jpg"> WHEN picture.jpg is located in the folder one level up from the current folder

    如何将超链接放到“目录树中的两个级别”? WHEN picture.jpg位于距离当前文件夹一级的文件夹中

    1. <img src="../../picture.jpg"> WHEN picture.jpg is located in the folder two levels up from the current folder
    2. 如何将超链接放到“目录树中的两个级别”? WHEN picture.jpg位于距离当前文件夹两级的文件夹中

Hope this example help :)

希望这个例子有帮助:)

Source: https://www.w3schools.com/html/html_filepaths.asp

资料来源:https://www.w3schools.com/html/html_filepaths.asp

#5


-3  

It is working for me to go back to two level (parent folder) through hyper link reference.

我正在通过超链接引用回到两级(父文件夹)。

#1


15  

You can use ../index.html to refer to index.html in the parent directory.

您可以使用../index.html来引用父目录中的index.html。

#2


14  

to go two level up use "../../" and your normal url from two level up folder.

升级两级使用“../../”和两个级别文件夹中的普通网址。

"../" in the path is used to go one level up. But, it can be used for more times, to go more levels up.

路径中的“../”用于向上一级。但是,它可以使用更多次,更高层次。

an example:

一个例子:

| HOME <br> 
+- image.jpg<br> 
|_
  |
  +- CONFIG<br>  
     |
     + PICTURE_CONFIG
       | 
       +- myfile.html

myfile.html contains:

myfile.html包含:

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

the second"../" goes from PICTURE_CONFIG to CONFIG folder
the first "../"goes from CONFIG to HOME folder
"image.jpg" searches in HOME folder for the file "image.jpg"

第二个“../”从PICTURE_CONFIG到CONFIG文件夹第一个“../"从CONFIG到HOME文件夹”image.jpg“在HOME文件夹中搜索文件”image.jpg“

#3


2  

I'm not sure exactly what you're asking, but in relative paths, ../ is 'up one level'.

我不确定你究竟在问什么,但在相对路径上,../是'上升一级'。

So, ../index.html would take you to the index of the next directory up. Hope that helps.

所以,.. / index.html会带你到下一个目录的索引。希望有所帮助。

#4


1  

  1. <img src="picture.jpg"> WHEN picture.jpg is located in the same folder as the current page

    如何将超链接放到“目录树中的两个级别”? WHEN picture.jpg与当前页面位于同一文件夹中

  2. <img src="images/picture.jpg"> WHEN picture.jpg is located in the images folder located in the current folder

    如何将超链接放到“目录树中的两个级别”? WHEN picture.jpg位于当前文件夹中的images文件夹中

  3. <img src="/images/picture.jpg"> WHEN picture.jpg is located in the images folder located at the root of the current web

    如何将超链接放到“目录树中的两个级别”? WHEN picture.jpg位于当前网站根目录的images文件夹中

  4. <img src="../picture.jpg"> WHEN picture.jpg is located in the folder one level up from the current folder

    如何将超链接放到“目录树中的两个级别”? WHEN picture.jpg位于距离当前文件夹一级的文件夹中

    1. <img src="../../picture.jpg"> WHEN picture.jpg is located in the folder two levels up from the current folder
    2. 如何将超链接放到“目录树中的两个级别”? WHEN picture.jpg位于距离当前文件夹两级的文件夹中

Hope this example help :)

希望这个例子有帮助:)

Source: https://www.w3schools.com/html/html_filepaths.asp

资料来源:https://www.w3schools.com/html/html_filepaths.asp

#5


-3  

It is working for me to go back to two level (parent folder) through hyper link reference.

我正在通过超链接引用回到两级(父文件夹)。