非常教程

SVG参考手册

分类 | Elements

path

入门

本教程将帮助您开始使用SVG路径。

<path>SVG元素是定义的形状的一般元件。所有的基本形状都可以用一个路径元素创建。

用法上下文

分类

图形元素,形状元素

允许的内容

任意数量的以下元素,以任何顺序排列:动画元素描述性元素

属性

全局属性

  • Conditional processing attributes
  • Core attributes
  • Graphical event attributes
  • Presentation attributes
  • class
  • style
  • externalResourcesRequired
  • transform

具体属性

  • d
  • pathLength
  • fillOpacity

DOM接口

这个元素实现了SVGPathElement接口。

例子

SVG

<svg width="100%" height="100%" viewBox="0 0 400 400"
     xmlns="http://www.w3.org/2000/svg">

  <path d="M 100 100 L 300 100 L 200 300 z"
        fill="orange" stroke="black" stroke-width="3" />
</svg>

结果

产品规格

Specification

Status

Comment

SVG PathsThe definition of '<path>' in that specification.

Working Draft

Scalable Vector Graphics (SVG) 2The definition of '<path>' in that specification.

Candidate Recommendation

Scalable Vector Graphics (SVG) 1.1 (Second Edition)The definition of '<path>' in that specification.

Recommendation

Initial definition

浏览器兼容性

Feature

Chrome

Edge

Firefox (Gecko)

IE

Opera

Safari

Basic support

1.0

(Yes)

1.5 (1.8)

9.0

8.0

3.0.4

Feature

Android

Edge

Firefox Mobile (Gecko)

IE Phone

Opera Mobile

Safari Mobile

Basic support

3.0

(Yes)

1.0 (1.8)

No support

(Yes)

3.0.4

SVG

可缩放矢量图形是基于可扩展标记语言(标准通用标记语言的子集),用于描述二维矢量图形的一种图形格式。它由万维网联盟制定,是一个开放标准。