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

116
Views
Establecer la altura de un div dinámicamente

Intento ajustar la altura de un div, en función de la altura de otro div. Parece bastante simple... Pero desafortunadamente, no funciona. Así que por favor dame una mano en esto. Aquí está mi código:

 anderblokhoogte = document.getElementById('slider-gaea'); var curblok = document.getElementById('curiculum'); curblok.clientHeight = anderblokhoogte.clientHeight + 'px !important';

Probé que el elemento 'slider-gaea' existe, pero la altura del cliente de 'anderblokhoogte' difiere de la altura que veo al inspeccionar este elemento. Pero también, el ajuste de curblok.clientHeight no da un cambio en la altura del elemento de destino.

Ya probé algunas opciones (otras propiedades como 'style.height', 'offsetHeight') pero no tengo idea de qué error cometí.

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

0

 anderblokhoogte = document.getElementById('slider-gaea'); var curblok = document.getElementById('curiculum'); document.getElementById('curiculum').style.height = anderblokhoogte.clientHeight + 'px';
 <div id="slider-gaea" style="height:100px;"> First Div Block </div> <div id="curiculum"> Second Div Block</div>

No puede establecer la altura usando .clientHeight en su lugar, use .style.height y también debe perder el !important al final.

Element.clientHeight es una propiedad de solo lectura.

Nota : Si bien HTMLElement.style también es una propiedad de solo lectura, es posible establecer un estilo en línea asignando una cadena directamente a la propiedad de estilo (consulte el ejemplo anterior).

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!