CSS :last-child Selector
例
親の最後の子である<p>要素の背景色を指定します。
p:last-child
{
background: #ff0000;
}
定義と使用法
:last-child
セレクターは、その親の最後の子であるすべての要素に一致します。
ヒント: p:last-childはp:nth-last-child(1)と同じです。
バージョン: | CSS3 |
---|
ブラウザのサポート
表の数字は、セレクターを完全にサポートする最初のブラウザーのバージョンを示しています。
Selector | |||||
---|---|---|---|---|---|
:last-child | 4.0 | 9.0 | 3.5 | 3.2 | 9.6 |
CSS構文
:last-child {
css declarations;
}