css 中設置單個文字樣式可以通過 text-decoration 屬性實現,可為文本添加下劃線、刪除線、上劃線或波浪線,語法為:text-decoration: none | underline | overline | line-through | wavy;。
CSS 中設置單個文字樣式
在 CSS 中,您可以使用 text-decoration
屬性來設置單個文字的樣式。此屬性允許您為文本添加下劃線、刪除線、上劃線或波浪線。
語法:
<code class="<a style='color:#f60; text-decoration:underline;' href=" https: target="_blank">css">text-decoration: none | underline | overline | line-through | wavy;</code>
登錄后復制
取值:
none:刪除所有文本裝飾。
underline:在文本下方添加下劃線。
overline:在文本上方添加上劃線。
line-through:在文本中間添加刪除線。
wavy:在文本下方添加一條波浪線。
使用示例:
要為特定文本元素添加下劃線,可以使用以下代碼:
<code class="css">.my-text { text-decoration: underline; }</code>
登錄后復制
要移除文本元素的刪除線,可以使用以下代碼:
<code class="css">.my-text { text-decoration: none; }</code>
登錄后復制
其他 CSS 屬性:
除 text-decoration
屬性外,CSS 還提供了一些其他屬性來控制文本樣式,例如:
color:設置文本顏色。
font-family:設置字體系列。
font-size:設置字體大小。
font-weight:設置字體粗細。