如果您没有设置 stroke-width ,则默认值为 1 1 个像素:
试试这个:
<svg height="30px"><text x="0" y="20" stroke-width="0" stroke="#000000">bla - svg stroke width 0</text></svg>
<svg height="30px"><text x="0" y="20" stroke="#000000">bla - svg stroke no width defined</text></svg>
<svg height="30px"><text x="0" y="20" stroke-width="1" stroke="#000000">bla - svg stroke width 1</text></svg>
<svg height="30px"><text x="0" y="20" stroke-width="2" stroke="#000000">bla - svg stroke width 2</text></svg>
此时
text-stroke 实际上在 webkit 中可用,使用供应商前缀。 text-fill也是如此。
在不久的将来它也可以在其他浏览器中使用,请在此处查看:http://caniuse.com/text-stroke
如何在 webkit 浏览器中使用:
https://developer.apple.com/library/safari/documentation/appleapplications/reference/SafariCSSRef/Articles/StandardCSSProperties.html#//apple_ref/doc/uid/TP30001266-_webkit_text_stroke
暂时
要在 CSS 中描边文本,您需要使用多个 text-shadow 来根据需要增加阴影以将其变为完整的描边颜色。
http://codepen.io/anon/pen/xklIi/
(用于描边效果的阴影越大,需要重复、重绘)
/* using CSS3 selector filters older browser, you can reset freely letter-spacing here */
[data-stroke="1"] {/* class can be used */
text-shadow:
0 0 1px red,
0 0 1px red,
0 0 1px red,
0 0 1px red,
0 0 1px red,
0 0 1px red,
0 0 1px red,
0 0 1px red,
0 0 1px red;
}
[data-stroke="2"] {
letter-spacing:2px /* you might need to reset letter-spacing to
keep text readable */
text-shadow:/* repeat until sharp enouggh */
0 0 2px red,
0 0 2px red,
0 0 2px red,
0 0 2px red,
0 0 2px red,
0 0 2px red,
0 0 2px red,
0 0 2px red,
0 0 2px red,
0 0 2px red;
}
HTML
<p data-stroke="1">bla - text stroke width 1</p>
<p data-stroke="2">bla - text stroke width 2</p>
<p data-stroke="2sharp">bla - text stroke sharp width 2</p>