CSS案例

:first-child - 匹配了 p 元素中的第一个 i 元素

 

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>饭桶教程(kuaikuaixuan.com)</title>
<style>
p > i:first-child
{
color:blue;
}
</style>
</head>
<body>
<p>I am a <i>strong</i> man. I am a <i>strong</i> man.</p>
<p>I am a <i>strong</i> man. I am a <i>strong</i> man.</p>
<p><b>注意:</b> 当 :first-child 作用于 IE8 以及更早版本的浏览器, !DOCTYPE 必须已经定义.</p>
</body>
</html>
运行一下