-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
Description
:nth-child() 选择器 实现奇偶行隔行换色
<!DOCTYPE html>
<html>
<head>
<style>
p:nth-child(2n)
{
/*background:#f2fbf2;*/
background-color: rgba(122, 191, 255, 0.10);
}
</style>
</head>
<body>
<h1> <code> :nth-child() 选择器 </code>实现奇偶行隔行换色</h1>
<p>第一个段落。</p>
<p>第二个段落。</p>
<p>第三个段落。</p>
<p>第四个段落。</p>
<p><b>注释:</b>所有主流浏览器均支持 :nth-child() 选择器,除了 IE8 及更早的版本。</p>
<p><b>定义和用法:</b> <code> :nth-child(n) </code> 选择器匹配属于其父元素的第 N 个子元素,不论元素的类型。
n 可以是数字、关键词或公式。</p>
</body>
</html>