選單
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

SVG 填充屬性


SVG 填充屬性

fill 屬性設定元素內部的顏色。

在這裡我們將介紹三個 fill 屬性

  • fill - 設定元素內部的顏色
  • fill-opacity - 設定元素內部顏色的不透明度
  • fill-rule - 設定用於確定形狀內部部分的演算法

SVG fill 屬性

fill 屬性定義了元素的內部顏色。

fill 屬性可用於以下 SVG 元素: <circle>, <ellipse>, <path>, <polygon>, <polyline>, <rect>, <text>, <textPath>, <tref> and <tspan>

fill 屬性的值可以是顏色名稱、rgb 值或十六進位制值。

這裡我們為多邊形、矩形、圓形和文字使用了 fill 屬性

I love SVG! Sorry, your browser does not support inline SVG.

這是 SVG 程式碼

示例

<svg width="600" height="220" xmlns="http://www.w3.org/2000/svg">
  <polygon points="50,10 0,190 100,190" fill="lime" />
  <rect width="150" height="100" x="120" y="50" fill="blue" />
  <circle r="45" cx="350" cy="100" fill="red" />
  <text x="420" y="100" fill="red">I love SVG!</text>
</svg>
自己動手試一試 »


SVG fill-opacity 屬性

fill-opacity 屬性定義了填充顏色的不透明度。

fill-opacity 屬性可用於以下 SVG 元素: <circle>, <ellipse>, <path>, <polygon>, <polyline>, <rect>, <text>, <textPath>, <tref> and <tspan>

fill-opacity 屬性的值從 0 到 1(或 0% 到 100%)。

這裡我們為多邊形、矩形、圓形和文字使用了 fill-opacity 屬性

I love SVG! Sorry, your browser does not support inline SVG.

這是 SVG 程式碼

示例

<svg width="600" height="220" xmlns="http://www.w3.org/2000/svg">
  <polygon points="50,10 0,190 100,190" fill="lime" fill-opacity="0.5" />
  <rect width="150" height="100" x="120" y="50" fill="blue" fill-opacity="50%" />
  <circle r="45" cx="350" cy="100" fill="red" fill-opacity="0.6" />
  <text x="420" y="100" fill="red" fill-opacity="70%">I love SVG!</text>
</svg>
自己動手試一試 »

SVG fill-rule 屬性

fill-rule 屬性定義了用於確定形狀內部部分的演算法。

fill-rule 屬性可用於以下 SVG 元素: <path>, <polygon>, <polyline>, <text>, <textPath>, <tref> and <tspan>

fill-rule 屬性的值可以是 "nonzero" 或 "evenodd"。

這裡我們為多邊形使用了 fill-rule 屬性,值為 "evenodd"

Sorry, your browser does not support inline SVG.

這是 SVG 程式碼

示例

<svg height="210" width="500" xmlns="http://www.w3.org/2000/svg">
  <polygon points="100,10 40,198 190,78 10,78 160,198" fill="lime" fill-rule="evenodd" />
</svg>
自己動手試一試 »

這裡我們為多邊形使用了 fill-rule 屬性,值為 "nonzero"

Sorry, your browser does not support inline SVG.

這是 SVG 程式碼

示例

<svg height="210" width="500" xmlns="http://www.w3.org/2000/svg">
  <polygon points="100,10 40,198 190,78 10,78 160,198" fill="lime" fill-rule="nonzero" />
</svg>
自己動手試一試 »

×

聯絡銷售

如果您想將 W3Schools 服務用於教育機構、團隊或企業,請傳送電子郵件給我們
sales@w3schools.com

報告錯誤

如果您想報告錯誤,或想提出建議,請傳送電子郵件給我們
help@w3schools.com

W3Schools 經過最佳化,旨在方便學習和培訓。示例可能經過簡化,以提高閱讀和學習體驗。教程、參考資料和示例會不斷審查,以避免錯誤,但我們無法保證所有內容的完全正確性。使用 W3Schools 即表示您已閱讀並接受我們的使用條款Cookie 和隱私政策

版權所有 1999-2024 Refsnes Data。保留所有權利。W3Schools 由 W3.CSS 提供支援