HTML:图片不会显示? [英] HTML: Image won't display?

查看:240
本文介绍了HTML:图片不会显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对HTML很陌生。我试图在我的网站上显示图片,但出于某种原因,它只显示一个带有问号的蓝色框。我在互联网上到处寻找,但没有任何解决方案似乎为我工作。我试过:

 < 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 。示例:

相对位置

 < img src =images / image.png> 

相对于文档位置查找图像。如果您的文档位于 http://example.com/site/document.html ,那么您的 images 文件夹应该与您的 document.html 文件位于同一个目录中。



绝对位置

 < img src =/ site / images / image.png> 
< img src =http://example.com/site/images/image.png>

 < img src =http://another-example.com/images/image.png> 

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



关于 / ..


$ b / 符号将始终返回文件系统或网站的根目录。



单点 ./ 指向您所在的目录。



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



所以你可以使用它们建立相关路线。



路线示例 http://example.com/dir/one/two/three/ 和您的调用文档位于 3 /



 ./ pictures / image.png

或者只是

 pictures / image.png

将尝试查找名为图片的目录内部 http://example.com/dir/one/two/three/

 ../ pictures / image.png

将尝试在 http://example.com/dir/one/two/ 内找到名为图片的目录。 。

 / pictures / image.png

将尝试直接在 / 处找到名为图片的目录或 example.com (它们是相同的),与目录相同。


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"/>

解决方案

Just to expand niko's answer:

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:

Relative location:

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

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

Absolute location:

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

or

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

In this case, your image will be sought from the document site's root, so, if your document.html is at http://example.com/site/document.html, the root would be at http://example.com/ (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.

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

"./pictures/image.png"

or just

"pictures/image.png"

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

"../pictures/image.png"

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

"/pictures/image.png"

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

这篇关于HTML:图片不会显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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