--- title: vector-effect slug: Web/SVG/Attribute/vector-effect translation_of: Web/SVG/Attribute/vector-effect ---
vector-effect 属性指明绘制对象时要使用的矢量效果。在任何其他合成操作(如滤镜,蒙版和剪辑等)之前,都要应用矢量效果。
备注: 作为显示性属性, vector-effect 也可以直接在 CSS 样式表中作为属性使用。
作为显示性属性,它能被应用到任何元素,但只对这10个元素有效果: {{SVGElement("circle")}}, {{SVGElement("ellipse")}}, {{SVGElement("foreignObject")}}, {{SVGElement("image")}}, {{SVGElement("line")}}, {{SVGElement("path")}}, {{SVGElement("polygon")}}, {{SVGElement("polyline")}}, {{SVGElement("rect")}}, {{SVGElement("text")}}, {{SVGElement("textPath")}} {{SVGElement("tspan")}}, and {{SVGElement("use")}}
| 值 | none | non-scaling-stroke | non-scaling-size | non-rotation | fixed-position |
|---|---|
| 默认值 | none |
| 可动画性 | 是 |
nonenon-scaling-strokenon-scaling-sizenon-scaling-stroke的特性。non-rotationfixed-position<svg viewBox="0 0 500 240">
<!-- normal -->
<path d="M10,20L40,100L39,200z" stroke="black" stroke-width="2px" fill="none"></path>
<!-- scaled -->
<path transform="translate(100,0)scale(4,1)" d="M10,20L40,100L39,200z" stroke="black"
stroke-width="2px" fill="none"></path>
<!-- fixed-->
<path vector-effect="non-scaling-stroke" transform="translate(300,0)scale(4,1)" d="M10,20L40,100L39,200z"
stroke="black" stroke-width="2px" fill="none"></path>
</svg>
{{EmbedLiveSample("Example_vector-effectnon-scaling-stroke", 550, 300)}}
| 规范 | 状态 | 备注 |
|---|---|---|
| {{SpecName("SVG2", "coords.html#VectorEffectProperty", "vector-effect")}} | {{Spec2("SVG2")}} | Initial definition |
{{Compat("svg.attributes.vector-effect")}}