在CSS中,您可以使用text-decoration
屬性來添加橫線到文字的前后,具體步驟如下:
1、添加橫線到文字前:
p::before { content: "— "; text-decoration: underline; }
2、添加橫線到文字后:
p::after { content: " —"; text-decoration: underline; }
3、完整示例:
<!DOCTYPE html> <html> <head> <style> p::before { content: "— "; text-decoration: underline; } p::after { content: " —"; text-decoration: underline; } </style> </head> <body> <p>這是一段帶有橫線的文字。</p> </body> </html>
在這個示例中,p
元素前后的文字都添加了橫線,您可以根據(jù)需要調(diào)整content
屬性的值來定制顯示的文字,希望這能幫助到您!
版權聲明:除非特別標注,否則均為本站原創(chuàng)文章,轉(zhuǎn)載時請以鏈接形式注明文章出處。