class=title
特定の使用を選択したい次のコードがありますnth-child
が、うまくいくようです
<div class="block">
<div class="title"></div> <!-- first title here !-->
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="title"></div> <!-- second title here !-->
<div class="item"></div>
<div class="title"></div> <!-- third title here !-->
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
テスト 1
.title:nth-child(3){
background-color: red;
}
期待される結果Third title highlighted
ですが、実際の出力はno highlight is done
テスト 2
.title:nth-child(1){
background-color: red;
}
期待される結果First title highlighted
実際の出力はfirst title is highlighted
最初の子のみで動作するのに、他の子では動作しない理由がわかりません..