我试图直接在其.page-container
父级中直接定位.row
的第一个实例。我无法使:first-of-type
选择器正确定位.row
的第一个实例。不能使用具有子选择器的第一种类型的选择器
.page-container > .row:first-of-type {
background: blue;
}
<div class="page-container">
<div class="row">Target This Row</div>
<div class="row">Don't Target</div>
<div class="row">Don't Target
<div class="row">Don't Target</div>
</div>
</div>
请帮我的目标只有.row
第一个实例是.page-container
的直系后裔。
https://jsfiddle.net/k54x0czj/ – potashin
作为@potashin指出的那样,你的代码似乎工作得很好。除非我们误解了你的问题? – Quiver