现在位置: 首页 > SVG 教程 > 正文

SVG 参考手册

SVG 规范中定义了更多的元素和属性。

常见 SVG 属性:

  • id: 元素的唯一标识符。
  • class: 元素的类名,用于CSS样式。
  • style: 元素的内联样式。
  • transform: 应用到元素上的变换。
  • x, y: 元素的位置。
  • width, height: 元素的尺寸。
  • fill: 填充颜色。
  • stroke: 描边颜色。
  • stroke-width: 描边宽度。
  • opacity: 透明度。
  • visibility: 元素的可见性。

SVG 元素列表如下:

元素 说明 属性
<svg> 定义 SVG 文档的根元素 width
height
viewBox
preserveAspectRatio
xmlns
...
<a> 定义超链接 xlink:href
target
...
<altGlyph> 定义替代的字形 glyphRef
format
rotate
dx
dy
...
<altGlyphDef> 定义用于 <altGlyph> 的替代的字形集合 (无)
<altGlyphItem> 定义 <altGlyphDef> 的可替代的字形 glyphRef
format
...
<animate> 定义动画 attributeName
from
to
dur
repeatCount
fill
...
<animateColor> 定义颜色动画 attributeName
from
to
dur
repeatCount
fill
...
<animateMotion> 定义路径动画 path
dur
repeatCount
...
<animateTransform> 定义变换动画 attributeName
type
from
to
dur
...
<circle> 定义圆形 cx
cy
r
fill
stroke
stroke-width
...
<clipPath> 定义剪切路径 clipPathUnits
(无)
<color-profile> 定义颜色配置文件 (无)
<cursor> 定义鼠标指针 x
y
width
height
xlink:href
...
<defs> 定义可重复使用的元素 (无)
<desc> 为 SVG 元素提供描述 (无)
<discard> 规定要丢弃的元素 (无)
<ellipse> 定义椭圆 cx
cy
rx
ry
fill
stroke
stroke-width
...
<feBlend> 定义图像混合 in
in2
mode
...
<feColorMatrix> 定义颜色矩阵 in
type
values
...
<feComponentTransfer> 定义颜色/Alpha 组件的转换函数 (无)
<feComposite> 定义图像合成 in
in2
operator
...
<feConvolveMatrix> 定义卷积矩阵 in
order
kernelMatrix
...
<feDiffuseLighting> 定义漫反射光照 in
surfaceScale
diffuseConstant
...
<feDisplacementMap> 定义位移图 in
in2
scale
...
<feDistantLight> 定义远程光照 azimuth
elevation
...
<feDropShadow> 定义投射阴影 dx
dy
stdDeviation
...
<feFlood> 定义用于图形元素的颜色 flood-color
flood-opacity
...
<feFuncA> 定义用于调整 Alpha 通道的曲线 type
tableValues
slope
...
<feFuncB> 定义用于调整图像的曲线 type
tableValues
slope
...
<feFuncG> 定义用于调整图像的曲线 type
tableValues
slope
...
<feFuncR> 定义用于调整图像的曲线 type
tableValues
slope
...
<feGaussianBlur> 定义高斯模糊效果 stdDeviation
...
<feImage> 定义要嵌入的图像 href
result
...
<feMerge> 定义用于合并图像的滤镜图形 (无)
<feMergeNode> 定义用于合并图像的输入图像 (无)
<feMorphology> 定义用于改变输入图像形状的滤镜 operator
radius
...
<feOffset> 定义输入图像的偏移 dx
dy
...
<fePointLight> 定义点光源 x
y
z
...
<feSpecularLighting> 定义镜面高光效果 in
surfaceScale
specularConstant
...
<feSpotLight> 定义聚光灯 x
y
z
pointsAtX
pointsAtY
pointsAtZ
...
<feTile> 定义重复输入图像 (无)
<feTurbulence> 定义湍流图像 baseFrequency
numOctaves
...
<filter> 定义滤镜效果 filterUnits
primitiveUnits
x
y
width
height
...
<font> 定义字体资源 horiz-origin-x
horiz-origin-y
horiz-adv-x
vert-origin-x
vert-origin-y
vert-adv-y
...
<font-face> 定义字体的属性 font-family
font-style
font-variant
font-weight
font-stretch
...
<font-face-format> 定义字体文件格式 (无)
<font-face-name> 定义字体名称 (无)
<font-face-src> 定义字体文件的位置 (无)
<font-face-uri> 定义字体文件的位置 (无)
<foreignObject> 定义 SVG 文件中的其它 XML 命名空