Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

203
Visualizações
CSS : selecting multiple nth-child

Say I have this css :

div div p:nth-child(1),
div div p:nth-child(2),
div div p:nth-child(3),
div div p:nth-child(4),
div div p:nth-child(5) {
}

This will select nth-child elements from 1 until 5.

And here are shortcuts

div div p:nth-child(n+1):nth-child(-n+5){
}

OR

div div p:nth-child(-n+5){
}

My question is,

How to select not the first element from 1 to 5, but the second element from 2 to 5 ?

So basically if I have this HTML :

<div>
    <div>
        <p></p>
        <p></p>
        <p></p>
    </div>
    <div>
        <p></p>
        <p></p>
        <p></p>
    </div>
    <div>
        <p></p>
        <p></p>
        <p></p>
    </div>
    <div>
        <p></p>
        <p></p>
        <p></p>
    </div>
    <div>
        <p></p>
        <p></p>
        <p></p>
    </div>
</div>

I would like it to apply a css background-color: red, only from the second div > p, and this until the 5th one.

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

perhaps something like this would work?

div div p:not(:first-child)

found in Style every thing except first child

about 4 years ago · Juan Pablo Isaza Relatório

0

Is this what you're looking for? Where the first set isn't selected but the rest are?

div div:not(:first-child) p {
  background-color: blue;
}

Fiddle Here.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda