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

98
Views
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
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!