CSS ::first-line 伪元素
定义和用法
CSS ::first-line 伪元素用于设置块级元素的第一行的样式。
注意:以下属性可以与 ::first-line 一起使用:
- 所有字体属性
- 所有背景属性
- color
- text-shadow
- word-spacing
- letter-spacing
- text-transform
- text-decoration
- text-decoration-color
- text-decoration-line
- text-decoration-style
- vertical-align
- line-height
实例
选择并设置每个 <p> 元素的第一行的样式:
p::first-line {
font-size: 20px;
text-decoration: underline;
background-color: lightgreen;
}
CSS 语法
::first-line {
css declarations;
}
技术细节
| 版本: | CSS1 |
|---|
浏览器支持
表格中的数字指定了完全支持该伪元素的首个浏览器版本。
| Chrome | Edge | Firefox | Safari | Opera |
|---|---|---|---|---|
| 1.0 | 9.0 | 1.0 | 1.0 | 7.0 |
相关页面
教程:CSS 伪元素