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

72
Views
Element fixed over multiple div's but relative to the last one

I have two div's with different background-color. I want the content to stay fixed while scrolling. But when the second div is in the viewport, I want it to be relative to it, so the content wont stay forever.

<div class="grandparent" id="grandparent">
  <div class="parent1" id="parent1">
    <div class="content" id="content"></div>
  </div>
  <div class="parent2" id="parent2"></div>
</div>

so the content should be fixed when scrolling over parent1 and parent2. But when i enter parent2, the content should be relative the parent2 so i can place other content.

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!