<polygon>

Baseline 广泛可用 *

此特性已相当成熟,可在许多设备和浏览器版本上使用。自 ⁨2015 年 7 月⁩以来,各浏览器均已提供此特性。

* 此特性的某些部分可能存在不同级别的支持。

<polygon> SVG 元素定义了一个由一系列连接的直线段组成的闭合形状。最后一个点连接到第一个点。

对于开放形状,请参阅 <polyline> 元素。

使用语境

分类基本形状元素、图形元素、形状元素
允许内容可包含任意数量、任意顺序的下列元素
动画元素
描述性元素

属性

此属性定义了绘制多边形所需的点列表(x,y 绝对坐标对)。值类型<number>+;默认值""可动画

路径长度

此属性允许指定路径的总长度(以用户单位)。值类型<number>默认值可动画

DOM 接口

此元素实现了 SVGPolygonElement 接口。

示例

html
<svg viewBox="0 0 200 100" xmlns="http://www.w3.org/2000/svg">
  <!-- Example of a polygon with the default fill -->
  <polygon points="0,100 50,25 50,75 100,0" />

  <!-- Example of the same polygon shape with stroke and no fill -->
  <polygon points="100,100 150,25 150,75 200,0" fill="none" stroke="black" />
</svg>

规范

规范
Scalable Vector Graphics (SVG) 2
# PolygonElement

浏览器兼容性

另见