Skip to content
  • Recent
  • Tags
  • Popular
  • Users
  • Search
Skins
  • Light
  • Brite
  • 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.8k Views 2 Watching
  • 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
    A
    aronsundberg
    wrote on 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
    • arminunruhA
      arminunruhA
      arminunruh
      Global Moderator
      wrote on last edited by arminunruh
      #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
      0
      • arminunruhA arminunruh

        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
        A
        aronsundberg
        wrote on 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
        • arminunruhA arminunruh

          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
          Z
          zochovsky
          wrote on last edited by zochovsky
          #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
            S
            stdhd
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0

            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

            With your input, this post could be even better 💗

            Register Login
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            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