Select certain number child or children selector withing parent. css
Is there a way to select a certain number of child selectors? For example
<div class="parent">
<div class="child-a">abc</div>
<div class="child-b">def</div>
<div class="child-c">ghi</div>
<div class="child-d">jkl</div>
<div class="child-e">m开发者_Python百科no</div>
<div class="child-f">pqr</div>
<div class="child-g">stu</div>
</div>
How can I select just .child-a, .child-b, .child-c
?
Or just select .child-d .child-e, .child-f
?
Can it be done with :nth-child pseudo-classes like
div.parent div:nth-child(1,2,3) { margin: 15px 0 0 0; display:inline }
div.parent div:nth-child(4,5,6) { margin: 30px 0 0 0; display:inline }
? something like that?
Well, if the div
s have those classes, you can simply list them:
.child-a, .child-b, .child-c
If you want to do it with nth-child
, you must list them like this:
.parent :nth-child(1), .parent :nth-child(2), .parent :nth-child(3)
精彩评论