CSSの役割:nth-last-child(n)セレクター
CSS:nth-last-child(n)セレクターを使用して、最後の子から数えて、親の子であるすべての
要素のスタイルを設定します。
次のコードを実行して、:nth-last-child(n)セレクター-
を実装してみてください。例
<!DOCTYPE html>
<html>
<head>
<style>
p:nth-last-child(4) {
background: blue;
color: white;
}
</style>
</head>
<body>
<p>This is demo text 1.</p>
<p>This is demo text 2.</p>
<p>This is demo text 3.</p>
<p>This is demo text 4.</p>
<p>This is demo text 5.</p>
<p>This is demo text 6.</p>
</body>
</html> 出力
-
CSSの役割:rootセレクター
CSS:ルートセレクターを使用して、ドキュメントのルート要素のスタイルを設定します。 例 次のコードを実行して、:root Selectorを実装してみてください。 <!DOCTYPE html> <html> <head> <style> :root { background: blue; &nbs
-
CSSの役割:必須のセレクター
CSS:requiredセレクターを使用して&amp; lt; input&amp;gt;のスタイルを設定します「必須」属性を持つ要素。次のコードを実行して、:requiredセレクターを実装してみてください: 例 <!DOCTYPE html> <html> <head> <style> input:required { bac