Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

394
Views
¿Cómo marcar/desmarcar la casilla de verificación haciendo clic fuera del bloque específico?

Así que tengo un div que aparece/desaparece al hacer clic en la casilla de verificación.

 <input type="checkbox" id="btn"> <div id="box"></div> #box { display: none; width: 100px; height: 100px; } #btn:checked + #box display: block; }

Pero también quiero agregar una opción para cerrarlo haciendo clic en cualquier lugar fuera de este cuadro. ¿Cómo puedo hacerlo?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Verifique el siguiente código. Puede usar label for lograr este comportamiento. Haces clic en un cuadro fuera de la casilla de verificación y se marca como querías.

 label { display: block; margin-top: 100px; width: 200px; height: 200px; background: limegreen; } #btn:checked~#box { display: block; } #box { margin-top: 50px; display: none; width: 200px; height: 200px; background: red; }
 <input type="checkbox" id="btn"> <label for="btn"></label> <div id="box"> </div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!