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

99
Vistas
Adjust width of absolute element based on relative parent layout changes

I'm making a ball bounce from div to div(with .bounce-on). In order to do that, I'm using absolute divs (with .orbit) positioned with JS to make the ball bounce from the middle to the middle of each div.

Here is the codepen: https://codepen.io/wearysigninup/pen/rNpNmoZ

.css-container{
  position:relative;
  text-align:center;
}

.orbit{
  top: -20px;
  position: absolute;
  width: 50px;
  height:50px;
  border: black 1px solid;
  border-radius:50%;
  transform: rotate(0deg);
}
<div class="css-container">
  <div class="orbit">
    <div id="ball"></div>    
  </div>
  ...
  <div class="orbit"></div>
</div>

<div class="line">
   <span class="bounce-on">bounce</span>·<span class="bounce-on">bounce</span> 
   <span class="bounce-on">bounce</span> <span class="bounce-on">bounce</span>·
   <span class="bounce-on">bounce</span>
</div>

I'd like to have the div.orbit adjust their width based on changes on .bounce-on without using javascript to recalculate stuff if possible. The timing of the animation is tied to music, and I'd like it to not get out of sync.

Could anyone help with that? Is there an html markup or some css calculations that would make this possible?

Right now, I'm listening to resizing event to adjust the size but it's getting the bouncing out of sync.

To my knowdledge, what I'm asking is not possible. But I came pretty close with svg text. Only problem with using svg, is that the event endlers are inconsistently triggered and not well supported accross browsers. Also, not very accessible.

I'm hoping it's somehow possible to mimic the svg behavior when resizing window with css, thus my question.

about 4 years ago · Juan Pablo Isaza
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