Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse

Lay Theme Forum

  1. Home
  2. General Discussion
  3. Change link-color on fixed nav based on current row-background

Change link-color on fixed nav based on current row-background

Scheduled Pinned Locked Moved General Discussion
5 Posts 4 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aronsundberg
    wrote on Oct 11, 2016, 11:42 AM last edited by
    #1

    Is there a way to change the color of links in a fixed nav menu based on the current background-color of the row. I know there's plugins like backgroundCheck but it only works on images.

    On my website there's a different bg-color for each section and when its a dark color the links wont show, obviously. Here's the website: www.aronsundberg.se

    Grateful for any help or advice!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      arminunruh
      Global Moderator
      wrote on Oct 11, 2016, 3:07 PM last edited by arminunruh Oct 11, 2016, 11:22 AM
      #2

      oh wow, nice website!

      Ok you got one black row and I guess you want to have white nav text just for that.
      Right click any rows where you want your menu to be white, choose "set html class/id" and set the class: blackrow

      Enter this js into "Custom <head> content" in "Custom CSS & HTML" in "Lay Options":

      <script>
          var offset = 50;
          var $blackRows;
          var $nav;
          
          Frontend.GlobalEvents.on("newpageshown", function(layoutObj, type, obj){
              $blackRows = jQuery(".blackrow");
              $nav = jQuery("nav");
              $nav.removeClass("white");
          });
          
          jQuery(document).on("scroll", function(){
              $blackRows.each(function(){
                  var rect = this.getBoundingClientRect();
                  if(rect.top - offset < 0 && rect.bottom - offset > 0){
                      $nav.addClass("white");
                      return false;
                  }else{
                      $nav.removeClass("white");
                  }
              });
          });
      </script>
      

      And this css into "Custom CSS for Desktop Version"

      nav.primary a{
          transition: all 200ms ease;
      }
      
      nav.primary.white a{
          color: white;
          opacity: 1;
      }
      
      A Z 2 Replies Last reply Oct 11, 2016, 3:30 PM
      0
      • A arminunruh
        Oct 11, 2016, 3:07 PM

        oh wow, nice website!

        Ok you got one black row and I guess you want to have white nav text just for that.
        Right click any rows where you want your menu to be white, choose "set html class/id" and set the class: blackrow

        Enter this js into "Custom <head> content" in "Custom CSS & HTML" in "Lay Options":

        <script>
            var offset = 50;
            var $blackRows;
            var $nav;
            
            Frontend.GlobalEvents.on("newpageshown", function(layoutObj, type, obj){
                $blackRows = jQuery(".blackrow");
                $nav = jQuery("nav");
                $nav.removeClass("white");
            });
            
            jQuery(document).on("scroll", function(){
                $blackRows.each(function(){
                    var rect = this.getBoundingClientRect();
                    if(rect.top - offset < 0 && rect.bottom - offset > 0){
                        $nav.addClass("white");
                        return false;
                    }else{
                        $nav.removeClass("white");
                    }
                });
            });
        </script>
        

        And this css into "Custom CSS for Desktop Version"

        nav.primary a{
            transition: all 200ms ease;
        }
        
        nav.primary.white a{
            color: white;
            opacity: 1;
        }
        
        A Offline
        A Offline
        aronsundberg
        wrote on Oct 11, 2016, 3:30 PM last edited by
        #3

        @arminunruh Wow thanks a lot for writing all that code, i'll try this immediately. Thanks so much for your help :100: :)

        1 Reply Last reply
        0
        • A arminunruh
          Oct 11, 2016, 3:07 PM

          oh wow, nice website!

          Ok you got one black row and I guess you want to have white nav text just for that.
          Right click any rows where you want your menu to be white, choose "set html class/id" and set the class: blackrow

          Enter this js into "Custom <head> content" in "Custom CSS & HTML" in "Lay Options":

          <script>
              var offset = 50;
              var $blackRows;
              var $nav;
              
              Frontend.GlobalEvents.on("newpageshown", function(layoutObj, type, obj){
                  $blackRows = jQuery(".blackrow");
                  $nav = jQuery("nav");
                  $nav.removeClass("white");
              });
              
              jQuery(document).on("scroll", function(){
                  $blackRows.each(function(){
                      var rect = this.getBoundingClientRect();
                      if(rect.top - offset < 0 && rect.bottom - offset > 0){
                          $nav.addClass("white");
                          return false;
                      }else{
                          $nav.removeClass("white");
                      }
                  });
              });
          </script>
          

          And this css into "Custom CSS for Desktop Version"

          nav.primary a{
              transition: all 200ms ease;
          }
          
          nav.primary.white a{
              color: white;
              opacity: 1;
          }
          
          Z Offline
          Z Offline
          zochovsky
          wrote on Apr 18, 2017, 12:59 PM last edited by zochovsky Apr 18, 2017, 9:39 AM
          #4

          @arminunruh

          Hey Armin,

          Thanks for the tip.

          That worked great, but is there any chance to make it work when the full screen slider is enabled on a page?

          Cheers

          1 Reply Last reply
          0
          • S Offline
            S Offline
            stdhd
            wrote on Nov 18, 2017, 7:46 AM last edited by
            #5

            Amazing! Would this be possibe with „Fullscreen Slider“ too?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            I also code custom websites or custom Lay features.
            💿 Email me here: 💿
            info@laytheme.com

            Before you post:
            1. When using a WordPress Cache plugin, disable it or clear your cache.
            2. Update Lay Theme and all Lay Theme Addons
            3. Disable all Plugins
            4. Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"

            This often solves issues you might run into

            When you post:
            1. Post a link to where the problem is
            2. Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
            3. If the problem is difficult to explain, post screenshots / link to a video to explain it
            Online Users
            Forgot your key, lost your files, need a previous Lay Theme or Addon version? Go to www.laykeymanager.com
            laytheme.com
            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Recent
            • Tags
            • Popular
            • Users
            • Search