Skip to content

Instantly share code, notes, and snippets.

@matiasemily
Created August 30, 2023 17:27
Show Gist options
  • Save matiasemily/2660bbb772a24c9995979c8f91e93db8 to your computer and use it in GitHub Desktop.
Save matiasemily/2660bbb772a24c9995979c8f91e93db8 to your computer and use it in GitHub Desktop.
Usando :nth-child
elemento-pai :nth-child(n) {
/* Estilos para o enésimo filho */
}
/* Exemplo: */
ul li:nth-child(2) {
background-color: yellow;
}
elemento-pai :nth-child(an + b) {
/* Estilos para os elementos que atendem à fórmula an + b */
}
/* Exemplo: */
ul li:nth-child(3n + 2) { /* n+3 a partir de 2, ou seja: 2, 5, 8, 11... */
color: blue;
font-weight: bold;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment