SVG <polyline>

SVG 折線 - <polyline>

例子 1

<polyline> 元素用于創建僅由直線組成的任何形狀(在多個點連接):

這是 SVG 代碼:

<svg height="200" width="500">
  <polyline points="20,20 40,25 60,40 80,120 120,140 200,180"
  style="fill:none;stroke:black;stroke-width:3" />
</svg>

親自試一試

代碼解釋:

  • points 屬性定義繪制折線所需的點列表(x 和 y 坐標對)

例子 2

另一個只有直線的例子:

這是 SVG 代碼:

<svg height="180" width="500">
  <polyline points="0,40 40,40 40,80 80,80 80,120 120,120 120,160"
  style="fill:white;stroke:red;stroke-width:4" />
</svg>

親自試一試