HTML:图像不会显示?

编程入门 行业动态 更新时间:2024-10-25 02:22:04
本文介绍了HTML:图像不会显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我对 HTML 有点陌生.我试图在我的网站上显示一个图像,但由于某种原因,它只显示一个带有问号的蓝色框.我在互联网上到处寻找,但似乎没有一个解决方案适合我.我试过了:

I'm kind of new to HTML. I'm trying to display an image on my website but for some reason, it just shows a blue box with a question mark in it. I've looked everywhere on the internet, but none of the solutions seemed to work for me. I've tried:

<img src="iwojimaflag.jpg"/> <img src="images/iwojimaflag.jpg"/> <img src="Applications/MAMP/htdocs/Symfony/src/Acme/WebBundle/Resources/public/images/iwojimaflag.jpg"/>

推荐答案

只是为了扩展niko的回答:

您可以通过其 URL 引用任何图像.不管它在哪里,只要它是可访问的,你就可以将它用作src.示例:

You can reference any image via its URL. No matter where it is, as long as it's accesible you can use it as the src. Example:

相对位置:

<img src="images/image.png">

搜索图像相对于文档的位置.如果您的文档位于 example/site/document.html,则您的 images 文件夹应位于 document.xml 所在的同一目录中.html 文件是.

The image is sought relative to the document's location. If your document is at example/site/document.html, then your images folder should be on the same directory where your document.html file is.

绝对位置:

<img src="/site/images/image.png"> <img src="example/site/images/image.png">

<img src="another-example/images/image.png">

在这种情况下,将从文档站点的根目录寻找您的图像,因此,如果您的 document.html 位于 example/site/document.html,根将在 example/(或者它是服务器文件系统上的相应目录,通常是 www/代码>).前两个示例是相同的,因为它们都指向同一主机,将第一个 / 视为服务器根目录的别名.在第二种情况下,图像位于另一个主机中,因此您必须指定图像的完整 URL.

In this case, your image will be sought from the document site's root, so, if your document.html is at example/site/document.html, the root would be at example/ (or it's respective directory on the server's filesystem, commonly www/). The first two examples are the same, since both point to the same host, Think of the first / as an alias for your server's root. In the second case, the image is located in another host, so you'd have to specify the complete URL of the image.

关于/、.和..:

Regarding /, . and ..:

/ 符号将始终返回文件系统或站点的根目录.

The / symbol will always return the root of a filesystem or site.

单点./指向你所在的同一个目录.

The single point ./ points to the same directory where you are.

双点 ../ 将指向上层目录,或者包含实际工作目录的目录.

And the double point ../ will point to the upper directory, or the one that contains the actual working directory.

因此您可以使用它们构建相对路由.

So you can build relative routes using them.

示例给出了路由 example/dir/one/two/three/ 和你的 calling 文档在 three/:

Examples given the route example/dir/one/two/three/ and your calling document being inside three/:

"./pictures/image.png"

或者只是

"pictures/image.png"

将尝试在 example/dir/one/two/three/ 中找到名为 pictures 的目录.

Will try to find a directory named pictures inside example/dir/one/two/three/.

"../pictures/image.png"

将尝试在 example/dir/one/two/ 中找到名为 pictures 的目录.

Will try to find a directory named pictures inside example/dir/one/two/.

"/pictures/image.png"

会尝试直接在 / 或 example(它们是相同的),在同一级别上找到名为 pictures 的目录作为目录.

Will try to find a directory named pictures directly at / or example (which are the same), on the same level as directory.

更多推荐

HTML:图像不会显示?

本文发布于:2023-07-27 02:53:09,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1219927.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:图像   HTML

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!