路径规划
Absolute links are easy to create, since they include the full path to the resource. Local links are a little harder, in the sense that the full path is not required, but rather it is relative between the document that contains the link and the file being linked to. The relative path has several advantages: paths are usually short, and will not change if entire site is moved to another server or domain.
绝对链接很容易创建,因为它们包含资源的完整路径。 从不需要完整路径的意义上讲, 本地链接要难一些,而是包含链接的文档和要链接到的文件之间的相对路径。 相对路径具有几个优点:路径通常很短,并且如果将整个站点移至另一个服务器或域,则路径不会更改。
![To-folder link](https://i-blog.csdnimg.cn/blog_migrate/863fe7a438d02088dd783d900aef0213.png)
<a href="myfiles/mystuff.html">
Go to my stuff</a>
If the file being linked from is inside a folder, and you wish to navigate to a file that contains the folder itself, you use ../ before the target. ../ means “go up one level”. For example, to get from a file inside a folder in a website to the index page on the root level of the site, you would use:
如果从中链接的文件位于文件夹内,并且您希望导航到包含该文件夹本身的文件,请在目标之前使用../ 。 ../表示“上一层楼”。 例如,要从网站文件夹中的文件获取网站根目录的索引页,可以使用:
<a href="../index.html">
This command is recursive, in the sense that "../../" means “go up two levels”.
此命令是递归的,在某种意义上, “ ../../”表示“上升两个级别”。
You can also use the two path modifiers in combination: for example: "../images/me.jpeg" means "go up one level from the current file, find a folder called images, and retrieve the file "me.jpeg". Or, for the illustration below, from a page called “products.html” that resides in a products folder, to get up and out of that folder and reach the index.html page that exists at the same level as the products folder, the code on the “products.html” page would be:
您还可以组合使用两个路径修饰符:例如: “ ../images/me.jpeg”的意思是“从当前文件上移一层 ,找到一个名为images的文件夹,然后检索文件” me.jpeg“ 。或者,如下图所示,从位于product文件夹中的“ products.html”页面上跳出该文件夹并到达与products文件夹相同级别的index.html页面, “ products.html”页面上的代码为:
<a href="../index.html">Go to the index page</a>
![out-of-folder link](https://i-blog.csdnimg.cn/blog_migrate/19442f60a19318cc4977d0ad745800d3.png)
/表示“转到网站的根目录”。 当活动页面埋在文件夹中时,这对Web页面可能是特别有用的技术。 无需导航到一系列“ ../../”中的根目录,您只需使用/即可实现快捷方式。 但是,此技术的实用性取决于您特定的Web服务器的设置:在学校将文件发布到此处的服务器时,这将无济于事,因为您无法在网站的根目录使用任何内容(您自己的工作将是几个嵌套的文件夹)。
路径规划