Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

184
Vistas
Adjacent div's children needs to be level vertically

There are 3 Vertical divs, as shown in the picture. There are some child divs inside each div that are shown by blue rectangles. I need the children divs to be level vertically. How can I do it?enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

As they said, in pure css/html is not possible if they are in separated containers. Using javascript you can first create the 'base' element (in this case, the inner divs of the center column), save its coord and then create the side ones and pos them with the saved coords.

This is a rough example, but can give the idea

for (let i = 1; i < 10; i++) {
  //Create the center column element first, from where to get the Y pos
  let elem2 = document.createElement('div');
  elem2.style.width = 'calc(100% - 10px)';
  elem2.style.height = '50px';
  elem2.style.margin = '5px';
  elem2.style.background = 'lightblue';
  document.querySelector('.col2').append(elem2);

  let coords = elem2.getBoundingClientRect(); //Getting coords data

  //creating first column elem
  let elem1 = document.createElement('div');
  elem1.style.position = 'absolute';
  elem1.style.top = coords.top + 'px'; //use de y pos from above
  elem1.style.width = 'calc(100% - 10px)';
  elem1.style.height = '25px';
  elem1.style.margin = '0 5px';
  elem1.style.background = 'pink';
  document.querySelector('.col1').append(elem1);

  //creating third column elem
  let elem3 = document.createElement('div');
  elem3.style.position = 'absolute';
  elem3.style.top = coords.top + 'px'; //use de y pos from above
  elem3.style.width = 'calc(100% - 10px)';
  elem3.style.height = '25px';
  elem3.style.margin = '0 5px';
  elem3.style.background = 'lightgreen';
  document.querySelector('.col3').append(elem3);
}
body,
html {
  margin: 0;
  padding: 0;
  background: lightyellow
}

.container {
  display: flex;
}

.col1 {
  position: relative;
  width: 75px;
  border: 2px solid red
}

.col2 {
  position: relative;
  flex-grow: 1;
  border: 2px solid blue
}

.col3 {
  position: relative;
  width: 150px;
  border: 2px solid green
}
<div class="container">
  <div class="col1">
  </div>

  <div class="col2">
  </div>

  <div class="col3">
  </div>

</div>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda