SVG <line>

SVG 直線 - <line>

<line> 元素用于創建一條線:

這是 SVG 代碼:

<svg height="210" width="500">
  <line x1="0" y1="0" x2="200" y2="200" style="stroke:rgb(255,0,0);stroke-width:2" />
</svg>

親自試一試

代碼解釋:

  • x1 屬性定義 x 軸上的線的起點
  • y1 屬性定義 y 軸上的線的起點
  • x2 屬性定義 x 軸上的線的終點
  • y2 屬性定義 y 軸上的線的終點