1. PROMO Upgrade to Pro Membership @ $99 / Lifetime & access all our 16+ premium Divi extensions: Divi Block, Carousel Toolkit, etc.LEARN MORE
Dismiss Notice
NEW Divi.Help Pro Carousel AI Toolkit - Magically turn your Divi design into carousel, simply by using our online toolkit. No plugins needed. Now it works with Divi 5 as well!Try our carousel AI toolkit
BEST Divi Block - A revolutionary drag & drop tool to easily mix & match 960+ premade blocks (Light & Dark) to kick start your Divi site design. Special module designs are included as well. Also newly added AI generator & color. Now it works with Divi 5 as well!
Learn More About Divi BlockFree Version ~ 340+ Free Blocks

Solved Is it possible to change the bg color of a section depending on the visibility of another section in

Discussion in 'Free Divi Community Forum' started by Asit Aithal, Mar 5, 2022.

  1. Asit Aithal

    Asit Aithal New Member
    Divi Block Pro Divi Ultimate Child Theme Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

    Is it possible to change the bg color of a section depending on the visibility of another section in the viewport?
     
    1. PRO MEMBER PERKS Divi Ultimate Blog Plugin - Easily set awesome default design for your Divi single blog page:Learn More
  2. Divi.Help

    Divi.Help Administrator
    Staff Member

    Any sample on that?
     
  3. Asit Aithal

    Asit Aithal New Member
    Divi Block Pro Divi Ultimate Child Theme Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

    sure. here's the link - https://www.innershaktiyoga.com/home-3/ The menu is sticky. If you click on any item, it scrolls down to that ID. So let's say that the user selects 'why choose us'
    the menu-strip should change to orange. and say if the user chooses 'testimonials' the menu-strip should change to white.
     
    1. PRO MEMBER PERKS Divi Login Customizer Plugin - Instantly beautify your Wordpress login page with 6 premade designs:Learn More
  4. Divi.Help

    Divi.Help Administrator
    Staff Member

    You may check out this tutorial: http://divisoup.com/how-to-highlight-active-links-on-scroll-and-click-for-one-page-divi-websites/

    But it's made to work with default Divi header. To make it work with Divi Theme Builder custom header, you may try to replace the below:

    $('#main-header #top-menu a:not(li.centered-inline-logo-wrap a), .et_slide_in_menu_container .et_mobile_menu li a').eq(i).addClass('ds-menu-active')

    with this:

    $('.et-menu>li>a').eq(i).addClass('ds-menu-active')

    =======

    Also replace the below:

    #main-header #top-menu a.ds-menu-active, .et_slide_in_menu_container .et_mobile_menu a.ds-menu-active {

    with this:

    .et-menu>li>a.ds-menu-active {

    And see if it works.
     
  5. Asit Aithal

    Asit Aithal New Member
    Divi Block Pro Divi Ultimate Child Theme Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

    it doesn't work. Here's the code:

    <script>
    jQuery(function ($) {
    $('.et-menu>li>a').eq(i).addClass('ds-menu-active') $(window).scroll(function () {
    var scrollPos = $(window).scrollTop();
    $('.ds-section').each(function (i) {
    var topPos = $(this).offset().top;
    if ((topPos - scrollPos) <= 80) {
    $('.ds-menu-active').removeClass('ds-menu-active')
    $('#main-header #top-menu a:not(li.centered-inline-logo-wrap a), .et_slide_in_menu_container .et_mobile_menu li a').eq(i).addClass('ds-menu-active')
    }
    })
    });
    });
    </script>

    /* Scroll menu active link*/
    .et-menu>li>a.ds-menu-active {
    color: #FE437D !important;
    }
     
    1. PRO MEMBER PERKS Divi Ultimate Header Plugin - Add more varieties for your Divi header (12 premade styles) + menu hover effects:Learn More
  6. Divi.Help

    Divi.Help Administrator
    Staff Member

  7. Asit Aithal

    Asit Aithal New Member
    Divi Block Pro Divi Ultimate Child Theme Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

    2022-03-06_18-56-23.png 2022-03-06_18-54-44.png 2022-03-06_18-54-44.png I put it in inspector. And this is what I see (attachment 1). However, it only works when I remove it (attachment 2)
     
    1. PRO MEMBER PERKS Divi.Help Pro Layout Packs - Agency Divi layout pack featuring unique comment design on single blog post page:View Demo
  8. Divi.Help

    Divi.Help Administrator
    Staff Member

  9. Asit Aithal

    Asit Aithal New Member
    Divi Block Pro Divi Ultimate Child Theme Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

    works now. kinda. thx. it seems one off as I have a blank section right above the actual section to give an effect of the menu strip bg change.
     
    1. PRO MEMBER PERKS Divi Powerful Child Theme - Power up your Divi sites with tons of new functionalities & premade elements:Learn More
  10. Asit Aithal

    Asit Aithal New Member
    Divi Block Pro Divi Ultimate Child Theme Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

  11. Divi.Help

    Divi.Help Administrator
    Staff Member

    You may try to adjust the below value to 103:

    if ((topPos - scrollPos) <= 80) {
     
    1. PRO MEMBER PERKS Divi.Help Pro Layout Packs - Modern & powerful Agency Divi layout pack, featuring team carousel, sliding menu, etc.View Demo
  12. Asit Aithal

    Asit Aithal New Member
    Divi Block Pro Divi Ultimate Child Theme Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin

    works when I changed it to 230. The only thing that doesn't seem to work is 'contact' Is it because it's already in the viewport when 'our classes' is displayed?
     
  13. Divi.Help

    Divi.Help Administrator
    Staff Member

    This is because the top scrolling viewport is not able to reach the top part of your contact section. You will need to have a bigger height for the Contact / Footer section.
     
    1. PRO MEMBER PERKS Divi Block Pro - Premade team carousel design for your Divi site without using any plugins:View Demo
  14. Asit Aithal

    Asit Aithal New Member
    Divi Block Pro Divi Ultimate Child Theme Divi Powerful Child Theme Divi Ultimate Archive Plugin Divi Ultimate Blog Plugin Divi Ultimate Header Plugin Divi Ultimate Footer Plugin