-webkit-text-stroke

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>

笔触颜色。

形式定义

初始值as each of the properties of the shorthand:
适用元素all elements
是否是继承属性yes
计算值as each of the properties of the shorthand:
Animation typeas each of the properties of the shorthand:

形式语法

-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 Standard
# the-webkit-text-stroke

浏览器兼容性

BCD tables only load in the browser

参见