Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

SVG image element

SVG的<image>元素允许在一个SVG对象内部呈现光栅图像。

在这个基本示例中,一个xlink:href 属性引用了一个将呈现在SVG对象中的.jpg图像:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" 
  "https://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="5cm" height="4cm" version="1.1"
     xmlns="https://www.w3.org/2000/svg" xmlns:xlink= "https://www.w3.org/1999/xlink">
	<image xlink:href="firefox.jpg" x="0" y="0" height="50px" width="50px"/>
</svg>

这里有一些重要的事情需要注意(引用自W3规范文档):

  • 如果你没有设置x属性或y属性,它们自动被设置为0。

  • 如果你没有设置height属性或width属性,它们自动被设置为0。

  • 如果width属性或height等于0,将不会呈现这个图像。

文档标签和贡献者

 此页面的贡献者: fanxiaojie
 最后编辑者: fanxiaojie,