color
color 属性用于为 fill、stroke、stop-color、flood-color 和 lighting-color 属性提供一个潜在的间接值:currentColor。
注意: 作为演示属性,color 还有一个对应的 CSS 属性:color。当两者都被指定时,CSS 属性具有优先权。
从技术上讲,color 可以应用于任何元素,但它对 SVG 元素没有直接影响。
用法说明
| 值 |
<color> | inherit |
|---|---|
| 默认值 | 取决于用户代理 |
| 可动画的 | 是 |
示例
html
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<g color="green">
<rect width="50" height="50" fill="currentColor" />
<circle
r="25"
cx="70"
cy="70"
stroke="currentColor"
fill="none"
stroke-width="5" />
</g>
</svg>
规范
| 规范 |
|---|
| CSS 颜色模块第四版 # the-color-property |
| Scalable Vector Graphics (SVG) 2 # ColorProperty |
浏览器兼容性
加载中…
另见
- CSS
color属性