:before :after

实例

在每个 <p> 元素的内容之前插入新内容:

p:before
{ 
content:"台词:";
}

<!DOCTYPE html>
<html>
<head>
<style>
p:before
{
content:"台词:";
background-color:yellow;
color:red;
font-weight:bold;
}
</style>
</head>

<body>

<p>我是唐老鸭。</p>
<p>我住在 Duckburg。</p>

<p><b>注释:</b>对于在 IE8 中工作的 :before,必须声明 DOCTYPE。</p>

</body>
</html>

原文地址:https://www.cnblogs.com/HuiLove/p/4923366.html