CSS ::first-letter 伪元素
定義和用法
CSS ::first-letter
伪元素用於設置塊級元素的第一个字母的樣式。
注意:以下屬性可以與 ::first-letter
一起使用:
- 所有字體屬性
- 所有背景屬性
- 所有外邊距屬性
- 所有內邊距屬性
- 所有邊框屬性
- color
- text-decoration
- text-shadow
- letter-spacing
- word-spacing
- text-transform
- text-decoration-color
- text-decoration-line
- text-decoration-style
- box-shadow
- vertical-align(僅當 float 為 none 時)
- line-height
- float
實例
選擇並設置每個 <p> 元素的第一个字母的樣式:
p::first-letter { font-size: 200%; font-weight: bold; color: #8A2BE2; }
CSS 語法
::first-letter { css declarations; }
技術細節
版本: | CSS1 |
---|
濾器支持
表格中的數字指定了完全支持該伪元素的首次濾器版本。
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
1.0 | 9.0 | 1.0 | 1.0 | 7.0 |
相关頁面
教程:CSS 伪元素