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

120
Views
javascript- transitioning through array of backgroundcolors on scroll for a single section

I'm trying to transition between background colors in a single section so that when a specific section (.bg_container) hits the top of the viewport the background color starts starts to smooth transition while scrolling. I've seen many examples of very nice background fades/transitions but they all assume that each section has it's own color.

The issue here is that i have more colors than sections, so i can't tie the background color to sections.

<script>
    
    var bg_colours = [
      "#f0f0ff",
      "#ff00ff",
      "#0ff00f",
      "#ffffff",
      "#000000",
    ];
    
</script>

<div class="main">
    
    <div class="header">
        <span>lorum ipsom</span>
    </div>
    
    <div class="module_one">
        <p>lorum ipsom</p>
    </div>
    
    <div class="module_two bg_container">
        <div class="bg_section height_100_percent">
            <div class="left_content">
                <p>lorum ipsom</p>
            </div>
            <div class="right_content">
                <p>lorum ipsom</p>
            </div>
        </div>
        <div class="bg_section height_100_percent">
            <div class="left_content">
                <p>lorum ipsom</p>
            </div>
            <div class="right_content">
                <p>lorum ipsom</p>
            </div>
        </div>
    </div>
    
    <div class="module_three">
        <p>lorum ipsom</p>
    </div>
    
    <div class="footer">
        <p>lorum ipsom</p>
    </div>
    
</div>

in the above sample i want to transition the background color for bg_container using a color array.

Thank you for your time!

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!