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

318
Visualizações
Make parent div cursor-pointer including child elements with inline styling?

I want to make an entire div cursor-pointer with inline CSS, but it currently only affects the whitespace around the child elements. I've tried position and z-index to no avail.

I do not and cannot have an external stylesheet.

<div className="cursor-pointer">
  <checkbox>
  <label>
</div>

Is there any way to do this without applying the cursor-pointer to every element? There's conditional logic as well so that would get pretty cluttered.

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Since you allow the usage of JS, you could use querySelectorAll to select all child elements and apply the same class to it:

let el = document.querySelectorAll('.cursor-pointer *');
el.forEach(ele => ele.classList.add('cursor-pointer'));
/* just for demonstration purpose */
.cursor-pointer {
  cursor: not-allowed;
}
<div class="cursor-pointer">
  <input type="checkbox">
  <label>Label</label>
</div>

about 4 years ago · Santiago Trujillo Relatório

0

Using javascript, this solution loops through the parent and children and applies the cursor directly to each element.

let pointers = document.querySelectorAll(".cursor-pointer");



pointers.forEach(function(el) {
  let children = el.querySelectorAll("*");
  children.forEach(function(c) {
    c.style.cursor = "pointer";
  });
  el.style.cursor = "pointer";
});
<div class="cursor-pointer">
  <input type="checkbox">
  <label>A</label>
</div>

about 4 years ago · Santiago Trujillo 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