<stop>

The SVG <stop> element defines a color and its position to use on a gradient. This element is always a child of a <linearGradient> or <radialGradient> 元素。

范例

<svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg"
     xmlns:xlink="http://www.w3.org/1999/xlink">
  <defs>
    <linearGradient id="myGradient" gradientTransform="rotate(90)">
      <stop offset="5%"  stop-color="gold" />
      <stop offset="95%" stop-color="red" />
    </linearGradient>
  </defs>
  <!-- using my linear gradient -->
  <circle cx="5" cy="5" r="4" fill="url('#myGradient')" />
</svg>

					

属性

offset

This attribute defines where the gradient stop is placed along the gradient vector. Value type : <number> | <percentage> ; 默认值 : 0 ; Animatable yes

stop-color

This attribute defines the color of the gradient stop. It can be used as a CSS property. Value type : currentcolor | <color> | <icccolor> ; 默认值 : black ; Animatable yes

stop-opacity

This attribute defines the opacity of the gradient stop. It can be used as a CSS property. Value type : <opacity> ; 默认值 : 1 ; Animatable yes

全局属性

Core Attributes

Most notably: id

Styling Attributes
class , style
Event Attributes

Global event attributes , Document element event attributes

Presentation Attributes

Most notably: color , display , stop-color , stop-opacity , visibility

用法注意事项

类别 Gradient element
准许内容 Any number of the following elements, in any order:
<animate> , <animateColor> , <set>

规范

规范
Scalable Vector Graphics (SVG) 1.1 (Second Edition) (SVG)
# GradientStops

浏览器兼容性

BCD tables only load in the browser

Found a problem with this page?

最后修改: , 由 MDN 贡献者