:nth-of-type() (selettore CSS e jQuery) riguarda gli elementi HTML che -secondo quanto passato nel suo parametro- siano di numero pari (even), dispari (odd) o l’n-esimo elemento (a partire dal primo dello stesso tipo).
Sintassi
:nth-of-type() {
/* codice */
}
Esempi
<style>
p:nth-of-type(odd) {
background-color: red;
}
p:nth-of-type(even) {
background-color: blue;
}
p:nth-of-type(3) {
background-color: yellow;
}
</style>
<p>Paragrafo 1.</p>
<p>Paragrafo 2.</p>
<p>Paragrafo 3.</p>
<p>Paragrafo 4.</p>
<p>Paragrafo 5.</p>
Paragrafo 1.
Paragrafo 2.
Paragrafo 3.
Paragrafo 4.
Paragrafo 5.
Contenuti correlati
- CSS
- HTML
- JavaScript
- jQuery
- PHP
- SQL
- WORDPRESS
0 Comment