-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.

Thuộc tính CSS -webkit-text-stroke chỉ định độ rộngmàu sắc của nét viền cho các ký tự văn bản. Đây là thuộc tính viết tắt cho các thuộc tính đầy đủ -webkit-text-stroke-width-webkit-text-stroke-color.

Thuộc tính thành phần

Thuộc tính này là viết tắt của các thuộc tính CSS sau:

Cú pháp

css
/* Giá trị độ rộng và màu */
-webkit-text-stroke: 4px navy;

/* Giá trị toàn cục */
-webkit-text-stroke: inherit;
-webkit-text-stroke: initial;
-webkit-text-stroke: revert;
-webkit-text-stroke: revert-layer;
-webkit-text-stroke: unset;

Giá trị

<length>

Độ rộng của nét viền.

<color>

Màu sắc của nét viền.

Định nghĩa hình thức

Initial valueas each of the properties of the shorthand:
Applies toall elements
Inheritedyes
Computed valueas each of the properties of the shorthand:
Animation typeas each of the properties of the shorthand:

Cú pháp hình thức

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

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

Ví dụ

Thêm nét viền văn bản màu đỏ

HTML

html
<p id="example">The stroke of this text is red.</p>

CSS

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

Kết quả

Đặc tả

Specification
Compatibility
# the-webkit-text-stroke

Tương thích trình duyệt

Xem thêm