路径规划_路径

路径规划

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 linkPaths between files in the same location are assumed by the browser, as we have seen. However, if the file being linked to is in a folder next to the current file (the one being linked from) then you must specify the folder name:
<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 linkFinally, the use of a single
/ before a file or directory name means “go to the root of the website”. It can be particularly useful technique on web pages when the active page is buried in a folder. Rather than navigating up to the root in a series of "../../", you can simply shortcut by using /. However the usefulness of this technique depends on the setup of your particular web server: it is not going to be helpful when we publish our files to the server here at school, as there will be nothing you can use at the root of the site (your own work will be several nested folders down).

/表示“转到网站的根目录”。 当活动页面埋在文件夹中时,这对Web页面可能是特别有用的技术。 无需导航到一系列“ ../../”中的根目录,您只需使用/即可实现快捷方式。 但是,此技术的实用性取决于您特定的Web服务器的设置:在学校将文件发布到此处的服务器时,这将无济于事,因为您无法在网站的根目录使用任何内容(您自己的工作将是几个嵌套的文件夹)。

翻译自: https://thenewcode.com/204/Paths

路径规划

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值