Thanks to visit codestin.com
Credit goes to github.com

Skip to content

:nth-child() 选择器:实现奇偶行隔行换色 #43

@qingquan-li

Description

@qingquan-li

: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>

nth-child _selector

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions