一,效果图。
二,代码。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>CSS 伪元素</title>
<style>
p:first-line {
color: #ff0000;
font-variant: small-caps;
}
p:first-letter {
color: #ff0000;
font-size: xx-large;
}
h1:before {
content: url(smiley.gif);
}
h1:after {
content: url(smiley.gif);
}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>第一行</p>
<p>第二行</p>
</body>
</html>
参考资料:《菜鸟教程》