--- title: stop slug: Web/SVG/Element/stop tags: - SVG - SVG渐变 - 元素 - 参考 - 需要示例 translation_of: Web/SVG/Element/stop ---
一个渐变上的颜色坡度,是用stop
元素定义的。stop
元素可以是{{SVGElement("linearGradient")}}元素或者{{SVGElement("radialGradient")}}元素的子元素。
{{svginfo}}
<svg width="100%" height="100%" viewBox="0 0 80 40" xmlns="http://www.w3.org/2000/svg"> <defs> <linearGradient id="MyGradient"> <stop offset="5%" stop-color="#F60" /> <stop offset="95%" stop-color="#FF6" /> </linearGradient> </defs> <!-- Outline the drawing area in black --> <rect fill="none" stroke="black" x="0.5" y="0.5" width="79" height="39"/> <!-- The rectangle is filled using a linear gradient --> <rect fill="url(#MyGradient)" stroke="black" stroke-width="1" x="10" y="10" width="60" height="20"/> </svg>
示例输出:
{{EmbedLiveSample("Example",160,95)}}
该元素实现了SVGStopElement
接口。
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | IE | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatIE('1.0')}} | {{CompatGeckoDesktop('1.8')}} | {{CompatIE('9.0')}} | {{CompatOpera('9.0')}} | {{CompatSafari('3.0.4')}} |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | {{CompatAndroid('3.0')}} | {{CompatGeckoMobile('1.8')}} | {{CompatNo}} | {{CompatVersionUnknown}} | {{CompatSafari('3.0.4')}} |
该表格基于这些资源。