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

198
Views
Cambiar el CSS del elemento secundario cuando se desplaza el elemento principal

En primer lugar, asumo que esto es demasiado complejo para CSS3, pero si hay una solución en alguna parte, me encantaría usarla.

El HTML es bastante sencillo.

 <div class="parent"> <div class="child"> Text Block 1 </div> </div> <div class="parent"> <div class="child"> Text Block 2 </div> </div>

El div secundario está configurado para mostrar: ninguno; por defecto, pero luego cambia a display:block; cuando se pasa el mouse sobre el div principal. El problema es que este marcado aparece en varios lugares de mi sitio, y solo quiero que el niño se muestre si el mouse está sobre su padre, y no si el mouse está sobre cualquiera de los otros padres (todos tienen la misma clase nombre y sin identificación).

Intenté usar $(this) y .children() sin éxito.

 $('.parent').hover(function(){ $(this).children('.child').css("display","block"); }, function() { $(this).children('.child').css("display","none"); });
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

¿Por qué no usar CSS?

 .parent:hover .child, .parent.hover .child { display: block; }

y luego agregue JS para IE6 (dentro de un comentario condicional, por ejemplo) que no admite :hover correctamente:

 jQuery('.parent').hover(function () { jQuery(this).addClass('hover'); }, function () { jQuery(this).removeClass('hover'); });

He aquí un ejemplo rápido: Fiddle

over 4 years ago · Santiago Trujillo Report

0

No es necesario usar JavaScript o jquery, CSS es suficiente:

 .child{ display:none; } .parent:hover .child{ display:block; }

VER DEMO

over 4 years ago · Santiago Trujillo Report

0

.parent:hover > .child { /*do anything with this child*/ }
over 4 years ago · Santiago Trujillo 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!