Thuộc tính ____1010 CSS đặt độ dày đột quỵ của đường trang trí được sử dụng trên văn bản trong một phần tử, chẳng hạn như một dòng, gạch chân hoặc tuyến đường.text-decoration-thickness =
0 CSS property sets the stroke thickness of the decoration line that is used on text in an element, such as a line-through, underline, or overline.
auto |
from-font |
|
Thử nó
Cú pháp
/* Single keyword */
text-decoration-thickness: auto;
text-decoration-thickness: from-font;
/* length */
text-decoration-thickness: 0.1em;
text-decoration-thickness: 3px;
/* percentage */
text-decoration-thickness: 10%;
/* Global values */
text-decoration-thickness: inherit;
text-decoration-thickness: initial;
text-decoration-thickness: revert;
text-decoration-thickness: revert-layer;
text-decoration-thickness: unset;
Giá trị
text-decoration-thickness =1
auto |
from-font |
|
Trình duyệt chọn một chiều rộng thích hợp cho dòng trang trí văn bản.
text-decoration-thickness =2
auto |
from-font |
|
Nếu tệp phông chữ bao gồm thông tin về độ dày ưa thích, hãy sử dụng giá trị đó. Nếu tệp phông chữ không bao gồm thông tin này, hãy hoạt động như thể
text-decoration-thickness =1 được đặt, với trình duyệt chọn độ dày thích hợp.
auto |
from-font |
|
text-decoration-thickness =4
auto |
from-font |
|
Chỉ định độ dày của dòng trang trí văn bản là
text-decoration-thickness =4, ghi đè đề xuất tệp phông chữ hoặc mặc định trình duyệt.
auto |
from-font |
|
text-decoration-thickness =6
auto |
from-font |
|
Chỉ định độ dày của dòng trang trí văn bản là
text-decoration-thickness =6 của 1EM trong phông chữ hiện tại. Một tỷ lệ phần trăm kế thừa như một giá trị tương đối, và do đó quy mô với các thay đổi trong phông chữ. Trình duyệt phải sử dụng tối thiểu 1 pixel thiết bị. Đối với một ứng dụng nhất định của thuộc tính này, độ dày không đổi trên toàn bộ hộp được áp dụng, ngay cả khi có các phần tử con với kích thước phông chữ khác nhau.1em in the current font. A percentage inherits as a relative value, and so therefore scales with changes in the font. The browser must use a minimum of 1 device pixel. For a given application of this property, the thickness is constant across the whole box it is applied to, even if there are child elements with a different font size.
auto |
from-font |
|
Định nghĩa chính thức
Cú pháp chính thức
text-decoration-thickness =
auto |
from-font |
|
Ví dụ
Độ dày khác nhau
HTML
Here's some text with a 1px red underline.
This one has a 5px red underline.
This uses the equivalent shorthand.
CSS
.thin {
text-decoration-line: underline;
text-decoration-style: solid;
text-decoration-color: red;
text-decoration-thickness: 1px;
}
.thick {
text-decoration-line: underline;
text-decoration-style: solid;
text-decoration-color: red;
text-decoration-thickness: 5px;
}
.shorthand {
text-decoration: underline solid red 5px;
}
Kết quả
Thông số kỹ thuật
Thông số kỹ thuật không xác định # chi tiết trang trí văn bản-chiều rộng # text-decoration-width-property |
Lưu ý: Tài sản được gọi là text-decoration-thickness =
8, nhưng đã được cập nhật vào năm 2019 lên
auto |
from-font |
|
text-decoration-thickness =
0. The property used to be called
auto |
from-font |
|
text-decoration-thickness =8, but was updated in 2019 to
auto |
from-font |
|
text-decoration-thickness =0.
auto |
from-font |
|
Tính tương thích của trình duyệt web
Bảng BCD chỉ tải trong trình duyệt
Xem thêm
Thuộc tính
text-decoration-thickness =0 trong CSS đặt độ dày đột quỵ của dòng trang trí được sử dụng trên văn bản trong một phần tử. Giá trị
auto |
from-font |
|
Here's some text with a 1px red underline.
This one has a 5px red underline.
This uses the equivalent shorthand.
1 cần phải là Here's some text with a 1px red underline.
This one has a 5px red underline.
This uses the equivalent shorthand.
2, Here's some text with a 1px red underline.
This one has a 5px red underline.
This uses the equivalent shorthand.
3 hoặc Here's some text with a 1px red underline.
This one has a 5px red underline.
This uses the equivalent shorthand.
4 để phản ánh thuộc tính độ dày..text {
text-decoration-line: underline;
text-decoration-thickness: 2px;
}
Cú pháp
text-decoration-thickness: auto | from-font | |
Giá trị
text-decoration-thickness =
1: [mặc định] cho phép trình duyệt chỉ định độ dày thích hợp cho dòng trang trí văn bản.
auto |
from-font |
|
text-decoration-thickness =
2: Nếu phông chữ có sẵn đầu tiên có số liệu chỉ định độ dày ưa thích, nó sẽ sử dụng độ dày đó; Nếu không, nó hoạt động như giá trị
auto |
from-font |
|
text-decoration-thickness =
1.
auto |
from-font |
|
text-decoration-thickness =
4: Bất kỳ độ dài hợp lệ nào với một đơn vị chỉ định độ dày của các dòng trang trí văn bản là một độ dài cố định. Điều này thay thế bất kỳ thông tin nào trong phông chữ và mặc định trình duyệt.
auto |
from-font |
|
9: Chỉ định độ dày của các dòng trang trí văn bản theo tỷ lệ phần trăm của 1EM trong phông chữ phần tử.Here's some text with a 1px red underline. This one has a 5px red underline. This uses the equivalent shorthand.
0: Cài đặt mặc định của thuộc tính, đó là.thin { text-decoration-line: underline; text-decoration-style: solid; text-decoration-color: red; text-decoration-thickness: 1px; } .thick { text-decoration-line: underline; text-decoration-style: solid; text-decoration-color: red; text-decoration-thickness: 5px; } .shorthand { text-decoration: underline solid red 5px; }
text-decoration-thickness =
1.
auto |
from-font |
|
2: Áp dụng giá trị độ dày trang trí của cha mẹ..thin { text-decoration-line: underline; text-decoration-style: solid; text-decoration-color: red; text-decoration-thickness: 1px; } .thick { text-decoration-line: underline; text-decoration-style: solid; text-decoration-color: red; text-decoration-thickness: 5px; } .shorthand { text-decoration: underline solid red 5px; }
3: Loại bỏ độ dày hiện tại khỏi phần tử..thin { text-decoration-line: underline; text-decoration-style: solid; text-decoration-color: red; text-decoration-thickness: 1px; } .thick { text-decoration-line: underline; text-decoration-style: solid; text-decoration-color: red; text-decoration-thickness: 5px; } .shorthand { text-decoration: underline solid red 5px; }
Thử nghiệm
Thay đổi giá trị của
text-decoration-thickness =0 trong bản demo sau để xem thuộc tính ảnh hưởng đến trang trí văn bản của phần tử:
auto |
from-font |
|
Nó không đổi cho con cháu
Sau khi thiết lập trang trí cho một yếu tố, tất cả trẻ em của nó cũng sẽ có trang trí đó. Bây giờ hãy tưởng tượng chúng ta muốn thay đổi độ dày của trang trí cho một trong những đứa trẻ:
p {
text-decoration-line: underline;
text-decoration-color: green;
text-decoration-thickness: 0.2em;
}
p span {
text-decoration-thickness: 0.1em; /* Doesn't work */
}
Điều này không hoạt động vì độ dày trang trí được chỉ định bởi các yếu tố tổ tiên không thể bị ghi đè. Để hoạt động này, tính đặc hiệu trang trí cần được đặt cho chính phần tử:
p {
text-decoration-line: underline;
text-decoration-color: green;
text-decoration-thickness: 0.2em;
}
p span {
text-decoration-line: underline;
text-decoration-color: green;
text-decoration-thickness: 0.1em; /* It works! */
}
Tỷ lệ phần trăm và dòng thác
Đối với thuộc tính này, một độ dài sẽ kế thừa như một giá trị cố định và sẽ không mở rộng với phông chữ. Mặt khác, một tỷ lệ phần trăm sẽ kế thừa như một giá trị tương đối và do đó, quy mô với các thay đổi trong phông chữ khi nó kế thừa.
p {
text-decoration-thickness: 20%;
}
p span {
font-size: 20px;
text-decoration-line: underline;
text-decoration-thickness: inherit; /* = 20% */
}
Bản demo sau đây cho thấy sự so sánh giữa việc sử dụng giá trị EM và phần trăm trong trường hợp kế thừa và, như bạn có thể thấy, ở phía bên trái [trong đó chúng tôi đang sử dụng EM], giá trị kế thừa là một độ dài cố định. Điều đó có nghĩa là nó không quy mô với sự thay đổi trong phông chữ. Tuy nhiên, ở phía bên phải, văn bản thừa hưởng giá trị tương đối [trong trường hợp này là 20%]; Do đó, tỷ lệ độ dày với sự thay đổi trong phông chữ.
Mặc dù dự thảo làm việc hiện tại của các đặc điểm kỹ thuật TÀI LIỆU THAM KHẢO Giá trị phần trăm cho
text-decoration-thickness =0, nhưng hỗ trợ thực tế hiện được giới hạn ở Firefox.
auto |
from-font |
|
Sử dụng với .thin {
text-decoration-line: underline;
text-decoration-style: solid;
text-decoration-color: red;
text-decoration-thickness: 1px;
}
.thick {
text-decoration-line: underline;
text-decoration-style: solid;
text-decoration-color: red;
text-decoration-thickness: 5px;
}
.shorthand {
text-decoration: underline solid red 5px;
}
6
.thin {
text-decoration-line: underline;
text-decoration-style: solid;
text-decoration-color: red;
text-decoration-thickness: 1px;
}
.thick {
text-decoration-line: underline;
text-decoration-style: solid;
text-decoration-color: red;
text-decoration-thickness: 5px;
}
.shorthand {
text-decoration: underline solid red 5px;
}
Dự thảo làm việc hiện tại của đặc tả Mô -đun trang trí văn bản CSS Cấp độ 4 bao gồm
text-decoration-thickness =0 dưới dạng giá trị trong thuộc tính tốc ký
auto |
from-font |
|
.thin {
text-decoration-line: underline;
text-decoration-style: solid;
text-decoration-color: red;
text-decoration-thickness: 1px;
}
.thick {
text-decoration-line: underline;
text-decoration-style: solid;
text-decoration-color: red;
text-decoration-thickness: 5px;
}
.shorthand {
text-decoration: underline solid red 5px;
}
6..link {
text-decoration: underline solid green 1px;
}
/* The longhand equivalent */
.link {
text-decoration-line: underline;
text-decoration-style: solid;
text-decoration-color: green,
text-decoration-thickness: 1px;
}
Trong khi
.thin {
text-decoration-line: underline;
text-decoration-style: solid;
text-decoration-color: red;
text-decoration-thickness: 1px;
}
.thick {
text-decoration-line: underline;
text-decoration-style: solid;
text-decoration-color: red;
text-decoration-thickness: 5px;
}
.shorthand {
text-decoration: underline solid red 5px;
}
6 được hỗ trợ tốt, nhưng hỗ trợ cho việc bao gồm text-decoration-thickness =0 hiện được giới hạn ở Firefox.
auto |
from-font |
|
Hỗ trợ trình duyệt
Tài sản | Không | Không | 70 | Không | 12.1 | Không |
Tỷ lệ phần trăm | Không | Không | 76 | Không | Không | Không |
Tỷ lệ phần trăm | Không | Không | 70 | Không | Không | Không |
Tài sản | Không | Không | Không | 12.2 | Không |
Tỷ lệ phần trăm | Không | Không | Không | Không | Không |
Tỷ lệ phần trăm | Không | Không | Không | Không | Không |
Notes
- Tốc ký
- Android chrome