[英]Html relative paths using period
I'm confused as to when the following are used and what they mean, for example in the src attribute of an img tag. 我对何时使用以下内容及其含义感到困惑,例如在img标签的src属性中。
I know / means 'current directory' and ../ means 'up one directory' 我知道/表示“当前目录”,而../表示“上一个目录”
. Current Directory? <a href="." /> ./ Current Directory <img src="./image.png" /> / Root directory <img src="/image.png" /> ../ Up one directory <img src="../image.png" />
What is the difference between ./image.png and /image.png ./image.png和/image.png有什么区别
Updated : / means root directory of the site 更新 :/表示站点的根目录
/
means starting from the root directory. /
表示从根目录开始。 Whereas ./
is the current directory, though I'm not sure there's any need for it (unless you're planning on appending to a PATH
in Linux systems... happy to be wrong about that one). ./
是当前目录,尽管我不确定是否需要它(除非您打算在Linux系统中附加到PATH
...很高兴在该目录上出错)。
./image.png
will grab image.png relative to your current location. ./image.png
将获取相对于您当前位置的image.png。 Calling ./image.png on domain.tld/site/page.html
will look for the image at domain.tld/site/image.png
在domain.tld/site/page.html
上调用./image.png将在domain.tld/site/image.png
查找图像
/image.png
will look for the image in the root of your site. /image.png
将在您网站的根目录中查找图像。 domain.tld/image.png
../images/image.png
.
您也可以使用../images/image.png
东西。
If this was used on domain.tld/site/page.html
, the browser would load the image from domain.tld/images/image.png
如果将其用于domain.tld/site/page.html
,则浏览器将从domain.tld/images/image.png
加载图像
The / means the root directory. /表示根目录。 Use . 采用 。 For the current directory. 对于当前目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.