CSSの役割:nth-last-of-type(n)セレクター
CSS:nth-last-of-type(n)セレクターを使用して、最後の子から数えて、親の2番目の
要素であるすべての
要素を選択します。
例
次のコードを実行して、:nth-last-of-type(n)セレクターを実装してみてください。
<!DOCTYPE html>
<html>
<head>
<style>
p:nth-last-of-type(2) {
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>
</body>
</html> -
CSSの役割:フォーカスセレクター
:focusセレクターを使用して、フォーカスのある要素を選択します。次のコードを実行して、:focusセレクターを実装してみてください 例 <!DOCTYPE html> <html> <head> <style> input:focus { background-color: green;  
-
CSSの役割:nth-last-child(n)セレクター
CSS:nth-last-child(n)セレクターを使用して、最後の子から数えて、親の子であるすべての要素のスタイルを設定します。 次のコードを実行して、:nth-last-child(n)セレクター-を実装してみてください。 例 <!DOCTYPE html> <html> <head> <style> p:nth-last-child(4) {