2021年8月23日解決済み

nth-child、nth-of-type の書き方によって違いはありますか?

ユーザー

詳細 CSS セレクター編では以下のどちらか書き方になると習いました。実際動作していました。

.overlay.show ul > :nth-child(1) {
  transition-delay: .1s;  
}
.overlay.show li:nth-of-type(1) {
  transition-delay: .1s;  
}

ただし、今回のレッスンでは以下の書き方でした。

.overlay.show li:nth-child(1) {
  transition-delay: .1s;  
}

どれも同じだと思いますが、どの書き方を選択するか違いはありますか?

スタッフ

この回答を見るにはプレミアムプランへの登録が必要です

プレミアムプランとは?