如何告诉HTML查找图像的路径? [英] How do I tell HTML a path to find an image?

查看:115
本文介绍了如何告诉HTML查找图像的路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的HTML文件保存在单独的文件夹中,并且我的所有图像都保存在该文件夹中,如何编写获取图像的路径?

If my HTML file is saved in a separate folder to the one with all my images in, how do I write a path to get the image?

例如,我写(我已经试过了)

For example, I write (i have tried both)

<img class="float" src="../CSS/images/web.jpg" alt="web developer directory">

<img class="float" src="/CSS/images/web.jpg" alt="web developer directory">

然而,当我查看页面时,这不会显示图像。

however this does not then display the image when I view the page.

我很欣赏这似乎是一个微不足道的问题,但是我的知识有限,我找不到解决方案。

I appreciate this may seem like a trivial question, however my knowledge is limited and I cannot find the solution.

感谢您的帮助。

推荐答案

您可以设置相对路径或绝对路径。
相对路径的示例是:

You can set either relative or absolute path. Example of relative path is:

/CSS/images/web.jpg

,绝对路径如下:

http://www.yoursite.com/CSS/images/web.jpg

您的例子似乎没问题。
请务必检查您的路径是否正确(您的图片是否真的在CSS文件夹中?)。还要检查你的图片扩展名是否正确(.jpg或.jpeg)。

Your example seems to be ok. Be sure to check if your path is correct (are your images really inside CSS folder?). Also check if your picture extension is correct (.jpg or .jpeg).

关于img标签和示例这里

About img tag and examples here

这篇关于如何告诉HTML查找图像的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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