<line>

Baseline 已廣泛支援

此特性已相當成熟,可在許多裝置和瀏覽器版本上使用。自 ⁨2015 年 7 月⁩以來,各瀏覽器均已提供此特性。

<line> SVG 元素是一個 SVG 基本形狀,用於建立連線兩個點的線。

使用語境

分類基本形狀元素、圖形元素、形狀元素
允許內容可包含任意數量、任意順序的下列元素
動畫元素
描述性元素

屬性

x1

定義線條起點的 X 軸座標。值型別<length> | <percentage> | <number>預設值0可動畫

x2

定義線條終點的 X 軸座標。值型別<length> | <percentage> | <number>預設值0可動畫

y1

定義線條起點的 Y 軸座標。值型別<length> | <percentage> | <number>預設值0可動畫

y2

定義線條終點的 Y 軸座標。值型別<length> | <percentage> | <number>預設值0可動畫

路徑長度

定義使用者單位的總路徑長度。值型別<number>預設值可動畫

DOM 介面

此元素實現了 SVGLineElement 介面。

示例

html
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  <line x1="0" y1="80" x2="100" y2="20" stroke="black" />

  <!-- If you do not specify the stroke
       color the line will not be visible -->
</svg>

規範

規範
Scalable Vector Graphics (SVG) 2
# LineElement

瀏覽器相容性

另見