html src属性变量
描述 (Description)
The src attribute instructs the browser where on the server it should look for the image that’s to be presented to the user. This may be an image in the same directory, an image somewhere else on the same server, or an image stored on another server.
src属性指示浏览器应在服务器上查找要呈现给用户的图像。 这可能是同一目录中的映像,同一服务器上其他位置的映像或另一服务器上存储的映像。
The example refers to an image that’s located in the same directory as the web page that’s calling it, but if the image was stored in a directory that was one level higher than the referencing document, the syntax would be as follows:
该示例引用的图像与调用它的网页位于同一目录中,但是如果该图像存储在比引用文档高一级的目录中,则语法将如下所示:
<img src="../giant-prawn.jpg" alt="The Giant Prawn at Ballina"/>
Here, ../ equates to “move up one directory in the hierarchy.”
在此, ../等于“在层次结构中上移一个目录”。
You can also reference an image relative to the web site’s root (that is, any file or folder after the domain name):
您还可以引用相对于网站根目录的图像(即域名之后的任何文件或文件夹):
<img src="/giant-prawn.jpg" alt="The Giant Prawn at Ballina"/>
This basically means “display the image giant-prawn.jpg that can be found in www.example.com/.” This is a very handy way of referencing the file, as you could move the document that referenced the image to any location on the file system without breaking the link.
这基本上意味着“显示可在www.example.com/中找到的图像Giant-prawn.jpg”。 这是引用文件的一种非常方便的方法,因为您可以将引用该图像的文档移动到文件系统上的任何位置,而无需断开链接。
If you’re referencing an image that’s held on another server, you’d express the src using a complete URI, as follows:
如果要引用保存在另一台服务器上的图像,则可以使用完整的URI来表示src,如下所示:
<img src="http://www.example.com/giant-prawn.jpg"
alt="The Giant Prawn at Ballina"/>
例 (Example)
The src attribute for this image shows that the image is located in the same directory as the web page:
该图像的src属性显示该图像与网页位于同一目录中:
<img src="giant-prawn.jpg" alt="The Giant Prawn at Ballina"/>
值 (Value)
This attribute takes as its value the location of the image relative to the referencing document, relative to the server root, or as a complete URI containing the http:// protocol, the server name, and the path to the document on that server.
此属性将图像相对于参考文档的位置,相对于服务器根目录的位置,或包含http://协议,服务器名称以及该服务器上文档路径的完整URI用作其值。
html src属性变量
本文详细解析了HTML中img标签的src属性,介绍了如何通过src属性指定本地或远程服务器上的图片资源,包括相对路径和绝对路径的使用方法。
2775

被折叠的 条评论
为什么被折叠?



