SVG Stroke 屬性
SVG Stroke 屬性
SVG提供了一個範圍廣泛stroke 屬性。在本章中,我們將看看下麵:
- stroke
- stroke-width
- stroke-linecap
- stroke-dasharray
所有stroke屬性,可應用於任何種類的線條,文字和元素就像一個圓的輪廓。
SVG stroke 屬性
Stroke屬性定義一條線,文本或元素輪廓顏色:
下麵是SVG代碼:
實例
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<g fill="none">
<path stroke="red" d="M5 20 l215 0" />
<path stroke="blue" d="M5 40 l215 0" />
<path stroke="black" d="M5 60 l215 0" />
</g>
</svg>
<g fill="none">
<path stroke="red" d="M5 20 l215 0" />
<path stroke="blue" d="M5 40 l215 0" />
<path stroke="black" d="M5 60 l215 0" />
</g>
</svg>
對於Opera用戶:(右鍵單擊SVG圖形預覽源)。
SVG stroke-width 屬性
Tstroke- width屬性定義了一條線,文本或元素輪廓厚度:
下麵是SVG代碼:
實例
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<g fill="none" stroke="black">
<path stroke-width="2" d="M5 20 l215 0" />
<path stroke-width="4" d="M5 40 l215 0" />
<path stroke-width="6" d="M5 60 l215 0" />
</g>
</svg>
<g fill="none" stroke="black">
<path stroke-width="2" d="M5 20 l215 0" />
<path stroke-width="4" d="M5 40 l215 0" />
<path stroke-width="6" d="M5 60 l215 0" />
</g>
</svg>
對於Opera用戶:(右鍵單擊SVG圖形預覽源)。
SVG stroke-linecap 屬性
strokelinecap屬性定義不同類型的開放路徑的終結:
下麵是SVG代碼:
實例
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<g fill="none" stroke="black" stroke-width="6">
<path stroke-linecap="butt" d="M5 20 l215 0" />
<path stroke-linecap="round" d="M5 40 l215 0" />
<path stroke-linecap="square" d="M5 60 l215 0" />
</g>
</svg>
<g fill="none" stroke="black" stroke-width="6">
<path stroke-linecap="butt" d="M5 20 l215 0" />
<path stroke-linecap="round" d="M5 40 l215 0" />
<path stroke-linecap="square" d="M5 60 l215 0" />
</g>
</svg>
對於Opera用戶:(右鍵單擊SVG圖形預覽源)。
SVG stroke-dasharray 屬性
strokedasharray屬性用於創建虛線:
下麵是SVG代碼:
實例
<svg xmlns="http://www.w3.org/2000/svg" version="1.1">
<g fill="none" stroke="black" stroke-width="4">
<path stroke-dasharray="5,5" d="M5 20 l215 0" />
<path stroke-dasharray="10,10" d="M5 40 l215 0" />
<path stroke-dasharray="20,10,5,5,5,10" d="M5 60 l215 0" />
</g>
</svg>
<g fill="none" stroke="black" stroke-width="4">
<path stroke-dasharray="5,5" d="M5 20 l215 0" />
<path stroke-dasharray="10,10" d="M5 40 l215 0" />
<path stroke-dasharray="20,10,5,5,5,10" d="M5 60 l215 0" />
</g>
</svg>
對於Opera用戶:(右鍵單擊SVG圖形預覽源)。