CSS---伪类的使用

p:first-child {font-weight: bold;}//将作为某元素第一个子元素的所有 p 元素设置为粗体
li:first-child {text-transform:uppercase;}//将作为某个元素(在 HTML 中,这肯定是 ol 或 ul 元素)第一个子元素的所有 li 元素变成大写

input:focus{background-color:yellow;}

//如果已规定 !DOCTYPE,那么 Internet Explorer 8 (以及更高版本)支持 :focus 伪类。

p:first-line{color: #ff0000;font-variant: small-caps}//对 p 元素的第一行文本进行格式化

p:first-letter { color:#ff0000; font-size:xx-large;}//伪元素用于向文本的首字母设置特殊样式

h1:before{content:url(logo.gif);}//每个 <h1> 元素前面插入一幅图片

h1:after{content:url(logo.gif);}//在每个 <h1> 元素后面插入一幅图片

原文地址:https://www.cnblogs.com/beast-king/p/3639316.html