English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
:last-of-type CSS pseudo-class indicates the last element of a given type in the list of child elements of its parent element. When the code similar to Parent tagName:last-of-type has the effect area containing the last selected element among all child elements of the parent element, including the last child element of the child elements and so on.
Manuale completo delle scelte CSS
Specificare il colore di sfondo dell'ultimo elemento p del genitore:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Corso di base(oldtoolbag.com)</title> <style> p em:last-of-type { color: verde; } </style> </head> <body> <p> <em>Non ho colore :(</em><br> <strong>Non ho colore :(</strong><br> <em>Ho colore :D</em><br> <strong>Non ho colore :(</strong><br> </p> <p> <em>Non ho colore :(</em><br> <span><em>Ho colore!</em></span><br> <strong>Non ho colore :(</strong><br> <em>Ho colore :D</em><br> <span> <em>Sono在内的子元素,但没有颜色!</em><br> <span style="text-decoration:line-through;"> Non ho colore </span><br> <em>Ho colore!</em><br> </span><br> <strong>Non ho colore :(</strong> </p> </body> </html>Prova a vedere ‹/›
element:last-of-type { properties dello stile }
Il selettore :last-of-type abbinamento dell'elemento il cui genitore è l'ultimo figlio di tipo specifico.
Suggerimento: e :nth-last-of-type(1) hanno lo stesso significato.
I numeri nella tabella rappresentano la versione del primo browser che supporta l'attributo.
Selettore | |||||
---|---|---|---|---|---|
:last-of-type | 4.0 | 9.0 | 3.5 | 3.2 | 9.6 |