如何在不使用整个地址的情况下链接到不同目录中的文件? [英] How do I link to a file in a different directory without using the whole address?

查看:176
本文介绍了如何在不使用整个地址的情况下链接到不同目录中的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在我的计算机本地服务器上建立一个网站,计划上传到我的webhost,所有链接和相关路径都是完整的。但是,我遇到了一个问题,如何链接到层次链上更高的目录中的页面和图像。



例如,假设我的网站是关于食物,我的所有徽标和样式表都在.com目录中。然后我添加子目录fruit。当然,我可以把所有的水果图像都保存在水果目录中,但是如何链接到我的标志和样式表,并且当我将所有内容上传到我的webhost时,仍然有链接可以工作?当我在网上编辑网站时,只需插入整个地址就没有问题(如果我想要更改域名,但是会发生问题),但是在我的电脑上建立一个离线网站是造成一些组织问题。



帮助?

解决方案

您可以使用两个像这样的点:



../然后你想要的目录,如标志或假设你在一个子目录中工作,如你所说的水果。


I'm building a website on my computer's local server, with the plan to upload to my webhost with all the links and relative pathways intact. However, I've run into a problem with how to link to pages and images in directories higher up the hierarchy chain.

For example, let say my website is about food and all my logos and stylesheets are in the main .com directory. Then I add the subdirectory "fruit". Sure, I could keep all my Fruit images in the fruit directory, but how would I link back to my logo and stylesheet, and still have links that work when I upload everything to my webhost? When I would edit websites online, just plugging in the whole address was no problem (caused issues if I ever wanted to change the domain, but it would work), but building a website offline on my computer is causing some organizational issues.

Help?

解决方案

You can access the root directory using two dots like this:

../ and then your desired directory like logos or something assuming you are working inside a subdirectory as you mentioned "fruit".

这篇关于如何在不使用整个地址的情况下链接到不同目录中的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆