text-decoration-style
text-decoration-style CSS 屬性用於設定 text-decoration-line 指定的文字裝飾線的樣式。該樣式適用於所有透過 text-decoration-line 設定的文字裝飾線。
試一試
text-decoration-style: solid;
text-decoration-style: double;
text-decoration-style: dotted;
text-decoration-style: dashed;
text-decoration-style: wavy;
<section id="default-example">
<p>
I'd far rather be
<span class="transition-all" id="example-element">happy than right</span>
any day.
</p>
</section>
p {
font: 1.5em sans-serif;
}
#example-element {
text-decoration-line: underline;
}
如果指定的裝飾具有特定的語義含義,例如表示某些文字已被刪除的刪除線,建議作者使用 HTML 標籤(如 <del> 或 <s>)來表示此含義。由於瀏覽器在某些情況下可能會停用樣式,因此在這種情況下,語義含義不會消失。
當同時設定多個線條裝飾屬性時,使用 text-decoration 簡寫屬性可能更方便。
語法
css
/* Keyword values */
text-decoration-style: solid;
text-decoration-style: double;
text-decoration-style: dotted;
text-decoration-style: dashed;
text-decoration-style: wavy;
/* Global values */
text-decoration-style: inherit;
text-decoration-style: initial;
text-decoration-style: revert;
text-decoration-style: revert-layer;
text-decoration-style: unset;
值
正式定義
| 初始值 | solid |
|---|---|
| 應用於 | 所有元素。也適用於 ::first-letter 和 ::first-line。 |
| 繼承性 | 否 |
| 計算值 | 同指定值 |
| 動畫型別 | 離散 |
正式語法
text-decoration-style =
solid |
double |
dotted |
dashed |
wavy
示例
設定波浪下劃線
以下程式碼將建立一個紅色波浪下劃線
CSS
css
.wavy {
text-decoration-line: underline;
text-decoration-style: wavy;
text-decoration-color: red;
}
HTML
html
<p class="wavy">This text has a wavy red line beneath it.</p>
結果
規範
| 規範 |
|---|
| CSS 文字裝飾模組級別 3 # text-decoration-style 屬性 |
瀏覽器相容性
載入中…
另見
- 當同時設定多個線條裝飾屬性時,使用
text-decoration簡寫屬性可能更方便。 text-decoration-linetext-decoration-colortext-decoration-thicknesstext-underline-offset