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 colour of sitetitel/menu on black row + sticky row

change colour of sitetitel/menu on black row + sticky row

Scheduled Pinned Locked Moved General Discussion
2 Posts 2 Posters 47 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.
  • M Offline
    M Offline
    maxb
    wrote on last edited by maxb
    #1

    Re: Change nav and logo text to white/black when scrolling

    Hi!

    I use the code of this thread (white text on .darkrow / .blackrow) to change the color of my sitetitel and menu when scrolling over dark background (via jQuery) and combined it with sticky rows (via css).
    Have a look here: https://www.maxbrunnert.de/portfolio-neu/

    But I have two problems I don't get solved:

    when the sitetitel/menu changed to white once, it does not change back to black
    the underline color of my menu does not change. for the underlining of sitetitel it works...

    Could someone help me? I guess there is an error because of the combination

    This is the code I use in custom CSS:

    .white {
    color: white!important;
    }
    
    /* Sticky Row */
    .sticky-row {
    position: sticky;
    top: 0;
    }
    
    /* Dark Row + Sticky Row */
    .sticky-blackrow {
    background: transparent;
    position: sticky;
    top: 0;
    }
    

    And this in Custom HTML at bottom:

    <!-- Dark Row -->
    <script>
        var offset = 50;
        var $blackRows;
        var $nav;
        
        window.laytheme.on("newpageshown", function(layoutObj, type, obj){
            $blackRows = jQuery(".blackrow");
            $nav = jQuery("nav a, .sitetitle span");
            $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>
    
    <!-- Dark Row + Sticky Row -->
    <script>
        var offset = 50;
        var $blackRows;
        var $nav;
        
        window.laytheme.on("newpageshown", function(layoutObj, type, obj){
            $blackRows = jQuery(".sticky-blackrow");
            $nav = jQuery("nav a, .sitetitle span");
            $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>
    
    1 Reply Last reply
    0
    • arminunruhA Offline
      arminunruhA Offline
      arminunruh
      Global Moderator
      wrote on last edited by
      #2

      i think its because its sticky no?

      rect.top is always 0 after it sticks to the top

      u need to somehow change the logic of the code and the conditions to make it work with sticky

      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
      L
      luziaconzeta
      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