color-interpolation
Baseline 广泛可用 *
color-interpolation CSS 属性在 SVG 中用于指定 <linearGradient> 和 <radialGradient> SVG 元素要使用的颜色空间。
语法
css
/* Keyword values */
color-interpolation: auto;
color-interpolation: sRGB;
color-interpolation: linearRGB;
值
正式定义
| 值 | auto | sRGB | linearRGB |
|---|---|
| 应用于 | <linearGradient> 和 <radialGradient> |
| 默认值 | auto |
| 可动画的 | 离散 |
正式语法
color-interpolation =
auto |
sRGB |
linearRGB
示例
在第一个 SVG 中,<linearGradient> 元素不包含 color-interpolation 属性,颜色插值默认为 sRGB。第二个示例展示了使用 linearRGB 值进行颜色插值。
html
<svg width="450" height="70">
<title>Example of using the color-interpolation CSS Property</title>
<defs>
<linearGradient id="sRGB">
<stop offset="0%" stop-color="white" />
<stop offset="25%" stop-color="blue" />
<stop offset="50%" stop-color="white" />
<stop offset="75%" stop-color="red" />
<stop offset="100%" stop-color="white" />
</linearGradient>
</defs>
<rect x="0" y="0" width="400" height="40" fill="url(#sRGB)" stroke="black" />
<text x="0" y="60" font-family="courier" font-size="16">
no color-interpolation (CSS property)
</text>
</svg>
html
<svg width="450" height="70">
<title>Example of using the color-interpolation CSS Property</title>
<defs>
<linearGradient id="linearRGB">
<stop offset="0%" stop-color="white" />
<stop offset="25%" stop-color="blue" />
<stop offset="50%" stop-color="white" />
<stop offset="75%" stop-color="red" />
<stop offset="100%" stop-color="white" />
</linearGradient>
</defs>
<rect
x="0"
y="0"
width="400"
height="40"
fill="url(#linearRGB)"
stroke="black" />
<text x="0" y="60" font-family="courier" font-size="16">
color-interpolation: linearRGB; (CSS property)
</text>
</svg>
css
svg {
display: block;
}
#linearRGB {
color-interpolation: linearRGB;
}
规范
| 规范 |
|---|
| Scalable Vector Graphics (SVG) 2 # ColorInterpolationProperty |
浏览器兼容性
加载中…