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

241
Views
¿Cómo sombreo un div si su elemento secundario está enfocado?

Básicamente, quiero que searchBarFirstDiv forme una sombra cuando se selecciona searchBarInput

Estoy usando REACT.

Aquí está mi HTML para referencia:

 <div className={css.searchBarFirstDiv}> <label className={css.searchBarDivContent} for="location-search-input"> <div className={css.searchBarHeadingFont}>Location</div> <input id="location-search-input" placeholder="Where are you going?" className={css.searchBarInput} /> </label> </div>

¿Cómo hago esto?

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

0

Solución CSS pura

 #main { padding: 30px; margin: 31px; } #main:focus-within { box-shadow: 0px 0px 10px red; }
 <div id="main"> <input type="text" id="input" placeholder="focus me!"> </div>

about 4 years ago · Juan Pablo Isaza Report

0

Enfoque de vainilla JS:

 document.getElementsByClassName('searchBarInput')[0] .addEventListener('focus', function(){ triggerFocus(document.getElementsByClassName('searchBarFirstDiv')[0]); }); // Thanks to: https://stackoverflow.com/a/52450494/1352994 function triggerFocus(element) { var eventType = "onfocusin" in element ? "focusin" : "focus", bubbles = "onfocusin" in element, event; if ("createEvent" in document) { event = document.createEvent("Event"); event.initEvent(eventType, bubbles, true); } else if ("Event" in window) { event = new Event(eventType, { bubbles: bubbles, cancelable: true }); } element.focus(); element.dispatchEvent(event); }
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!