在CSS中,可以使用text-decoration
屬性為字體添加一劃線,可以將text-decoration
的值設(shè)置為line-through
,以在字體上添加一條刪除線,以下是一些示例代碼:
1、為單個(gè)字體添加一劃線:
p { text-decoration: line-through; }
2、為多個(gè)字體添加一劃線:
p, h1, h2 { text-decoration: line-through; }
3、添加一劃線的同時(shí)添加其他樣式:
p { text-decoration: line-through; color: red; font-size: 20px; }
在上面的示例中,p
元素和其他標(biāo)題元素(h1
和h2
)都被添加了一劃線,還可以添加其他樣式,如顏色和字體大小。
text-decoration
屬性不僅支持line-through
值,還支持其他值,如underline
(添加下劃線)和overline
(添加上劃線),這些值可以實(shí)現(xiàn)不同的裝飾效果。