class
為元素分配類名或一組類名。您可以將相同的類名或類名分配給任意數量的元素,但是,多個類名必須用空格字元分隔。
元素的類名起著兩個關鍵作用:
- 作為樣式表選擇器,當作者為一組元素分配樣式資訊時。
- 供瀏覽器通用使用。
您可以使用此 class 來使用 CSS 為 SVG 內容設定樣式。
使用語境
| 分類 | None |
|---|---|
| 值 | <class-names-list> |
| 可動畫的 | 是 |
示例
html
<html lang="en">
<body>
<svg
width="120"
height="220"
viewPort="0 0 120 120"
version="1.1"
xmlns="http://www.w3.org/2000/svg">
<style>
<![CDATA[
rect.rectClass {
stroke: #000066;
fill: #00cc00;
}
circle.circleClass {
stroke: #006600;
fill: #cc0000;
}
]]>
</style>
<rect class="rectClass" x="10" y="10" width="100" height="100" />
<circle class="circleClass" cx="40" cy="50" r="26" />
</svg>
</body>
</html>
元素
以下元素可以使用 class 屬性:
<a><circle><clipPath><defs><desc><ellipse><feBlend><feColorMatrix><feComponentTransfer><feComposite><feConvolveMatrix><feDiffuseLighting><feDisplacementMap><feFlood><feGaussianBlur><feImage><feMerge><feMorphology><feOffset><feSpecularLighting><feTile><feTurbulence><filter><foreignObject><g><image><line><linearGradient><marker><mask><path><pattern><polygon><polyline><radialGradient><rect><stop><svg><switch><symbol><text><textPath><title><tspan><use>
規範
| 規範 |
|---|
| Scalable Vector Graphics (SVG) 2 # ElementSpecificStyling |
瀏覽器相容性
載入中…