网页文件夹结构
我正在编写一个代码,其中所有图像都用前面的“/”引用,
例如:
<img alt="" class="repositioned" src="/images/top-b-strip.jpg" />
我有一个 wamp 服务器,我在其中运行代码,发现图像无法正确显示,直到我删除图像之前的前面的“/”。
<img alt="" class="repositioned" src="images/top-b-strip.jpg" />
有人能解释一下我在这里缺少的东西吗?
I am working on a code where all the images are referred with a preceding "/"
eg:
<img alt="" class="repositioned" src="/images/top-b-strip.jpg" />
I have a wamp server where I run the code and find that image is not coming correctly until I remove the prceeding "/" before images.
<img alt="" class="repositioned" src="images/top-b-strip.jpg" />
Can anybody explain anything I am missing here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在路径开头放置“/”表示它绝对位于服务器的根目录。例如, http://www.example.com/images/top-b- strip.jpg,实际上您可能将它们作为 http://www.example.com/somesubaccount/images/top-b-strip.jpg。
您可以阅读有关绝对路径与相对路径的更多信息,例如 http://www .communitymx.com/content/article.cfm?cid=230ad
Putting a "/" at the start of your path denotes that it's absolutely situated at the root of your server. For instance, http://www.example.com/images/top-b-strip.jpg, where as you may actually have them as http://www.example.com/somesubaccount/images/top-b-strip.jpg.
You can read more about absolute versus relative paths at, for instance, http://www.communitymx.com/content/article.cfm?cid=230ad
/images/top-b-strip.jpg
是绝对路径,您需要在其中使用相对< /em> 路径(没有第一个 /)。这意味着 images 实际上是 html 文件所在目录的子目录,而如果使用绝对路径,则 images 文件夹应该是文件系统根目录的子文件夹。
/images/top-b-strip.jpg
is an absolute path, where you need to use a relative path (without the first /).This means that images is actually a subdirectory of the directory where your html file is, while if you use the absolute path, the images folder is supposed to be a subfolder of the root directory of the file system.