Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

107
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda