-webkit-text-stroke

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2017.

CSS 属性 -webkit-text-stroke 指定了文本字符的笔触宽度和笔触颜色。此属性为全称属性 -webkit-text-stroke-width-webkit-text-stroke-color 的简写属性。

css
/* 宽度和颜色值 */
-webkit-text-stroke: 4px navy;
text-stroke: 4px navy;

/* 全局值 */
-webkit-text-stroke: inherit;
-webkit-text-stroke: initial;
-webkit-text-stroke: revert;
-webkit-text-stroke: revert-layer;
-webkit-text-stroke: unset;

属性构成

此属性为下列 CSS 属性的简写属性:

语法

取值

<length>

笔触宽度。

<color>

笔触颜色。

形式定义

初始值该简写所对应的每个属性:
适用元素所有元素
是否是继承属性
计算值该简写所对应的每个属性:
动画类型该简写所对应的每个属性:

形式语法

-webkit-text-stroke = 
<line-width> ||
<color>

<line-width> =
<length [0,∞]> |
thin |
medium |
thick

示例

添加红色文本笔触

HTML

html
<p id="example">此文本的笔触为红色的。</p>

CSS

css
#example {
  font-size: 3em;
  margin: 0;
  -webkit-text-stroke: 2px red;
}

结果

规范

Specification
Compatibility
# the-webkit-text-stroke

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
-webkit-text-stroke

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

参见