CSS :first-line 选择器
每个<p>元素的第一行选择的样式:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <style> p:first-line { background-color: yellow; } </style> </head> <body> <h1>WWF's Mission Statement</h1> <p>To stop the degradation of the planet's natural environment and to build a future in which humans live in harmony with nature, by; conserving the world's biological diversity, ensuring that the use of renewable natural resources is sustainable, and promoting the reduction of pollution and wasteful consumption.</p> </body> </html>
定义和用法
:first-line选择器用来指定选择器第一行的样式。
注意::first-line选择器可以使用以下属性:
- font properties
- color properties
- background properties
- word-spacing
- letter-spacing
- text-decoration
- vertical-align
- text-transform
- line-height
- clear
注意: "first-line" 选择器适用于块级元素中。
浏览器支持
表格中的数字表示支持该属性的第一个浏览器版本号。
选择器 | |||||
---|---|---|---|---|---|
::first-line | 1.0 | 9.0 部分从5.5 |
1.0 | 1.0 | 7.0 部分从3.5 |
相关文章
CSS 教程: CSS 伪类