3 回答
TA贡献1911条经验 获得超7个赞
nth-child
<div> <h1>Hello</h1> <p>Paragraph</p> <p>Target</p></div>
p:nth-child(2)
p
p:nth-of-type
p
p
).
div
.row .label
:nth-of-type(1)
div
.row
.icon
.label
nth-of-type(3)
$(function () { $('.row .label:first') .css({ backgroundColor:"blue" });});
TA贡献1804条经验 获得超8个赞
.label:nth-of-type(1)
div
.label
label
.
label
1
TA贡献1776条经验 获得超12个赞
<p>
<i>
<i>
<p>
<style> * { padding: 0; margin:0; } section p { width: 20px; height: 20px; border:solid 1px black; border-radius: 15px; margin:20px; float: left; } section i { width: 20px; height: 20px; border:solid 1px black; border-radius: 15px; margin:20px; float: left; } section p:nth-child(1) { background-color: green; /*first-child of p in the flow*/ } section i:nth-child(1) { background-color: red; /*[first-child of i in the flow]NO */ } section i:nth-of-type(1) { background-color: blue; /*the type i of first child in the flow*/ } </style></head><body> <section> <p></p> <p></p> <p></p> <p></p> <i></i> <p></p> <i></i> <p></p> <p></p> <p></p> </section></body>
section p:nth-child(1) { background-color: green; /*first-child of p in the flow*/ }
section i:nth-child(1) { background-color: red; /*[first-child of i in the flow]NO */ }
section i:nth-of-type(1) { background-color: blue; /*the type i of first child in the flow*/ }
- 3 回答
- 0 关注
- 399 浏览
相关问题推荐
添加回答
举报