搞不懂下面这个css样式加上:after之后就不起作用了

来源:互联网 发布:linux 系统 死机 日志 编辑:程序博客网 时间:2024/09/21 08:57
<!DOCTYPE html>
<html>
<head>
<style>
body p:first-child>a:after
{
background-color:yellow;
}
</style>
</head>
<body>
<p>这个段落是其父元素(body)的首个子元素。
<a>this is </a>
这里还有类
</p>
<h1>欢迎访问我的主页</h1>
<p>这个段落不是其父元素的首个子元素。</p>
<div>
<p>这个段落是其父元素(div)的首个子元素。
<div>
<a>this is </a>
</div>
这里还有类容
</p>
<p>这个段落不是其父元素的首个子元素。</p>
</div>


<p><b>注释:</b>对于 IE8 及更早版本的浏览器中的 :first-child,必须声明 <!DOCTYPE>。</p>


</body>
</html>
1 0