Different color for nav/sitetitle on different pages
-
Thank you very much, I understand. I'm sorry, I forgot to clarify ā I would like to change the "first row" nav/sitetitle BLACK and the following rows to WHITE links.
Would this be possible?
@absent do you have a link to your website so I can see? sounds like it should be possible!
-
My version is still on a local environment. I found this code in your forum, but isn't working 100% for me.
I add on the first row ".darkrow" as css class to make the nav/sitetitle black.
.white { color: #fff !important; }
<script> var offset = 50; var $blackRows; var $nav; window.laytheme.on("newpageshown", function(layoutObj, type, obj){ $blackRows = jQuery(".darkrow"); $nav = jQuery("nav a, .sitetitle span"); $nav.addClass("white"); }); jQuery(document).on("scroll", function(){ $blackRows.each(function(){ var rect = this.getBoundingClientRect(); if(rect.top - offset < 0 && rect.bottom - offset > 0){ $nav.removeClass("white"); return false; }else{ $nav.addClass("white"); } }); }); </script>
-
hmm could you explain a bit further about what you mean when you say "first row" in relation to the navbar?
it sounds like more than just the navbar/site title/menu item colours you want to change?
-
for rows for example, you can right click them in the gridder, click "set row html class and id" and add this class:
white
now add this to lay options -> custom css & html:
custom <head> content:
<script> var $canbewhite = false window.laytheme.on('newpageshown', function () { $canbewhite = jQuery('.white') addOrRemoveWhite() }) var offset = 50; jQuery(document).on('scroll', function () { addOrRemoveWhite() }) var addOrRemoveWhite = function () { var isOneWhite = false if (!$canbewhite) return $canbewhite.each(function () { if (this.getBoundingClientRect().top - offset < 0 && this.getBoundingClientRect().bottom - offset > 0) { isOneWhite = true } }) if (isOneWhite) { jQuery('body').addClass('white-header') } else { jQuery('body').removeClass('white-header') } } </script>
Important, we still need to add this CSS:
Custom CSS for Desktop Version:
/* your site title and navigation texts need to be black at first. then we invert them, when "white-header" class is added to the body */ /* invert your site title */ body.white-header .sitetitle{ filter: invert(1); } /* invert your nav */ body.white-header > .laynav { filter: invert(1); }
Custom CSS for Mobile Version:
/* optional: make mobile site title, burger and cart icon white */ body.white-header .burger-wrap { filter: invert(1); } body.white-header .lay-cart-icon-wrap { filter: invert(1); } body.white-header .mobile-title{ filter: invert(1); } /* optional: make mobile things black again when mobile menu is opened */ body.white-header.mobile-menu-open .burger-wrap { filter: invert(0); } body.white-header.mobile-menu-open .lay-cart-icon-wrap{ filter: invert(0); } body.white-header.mobile-menu-open .mobile-title{ filter: invert(0); }
-
i did some changes to the code,
for the phone version we also invert the burger, before i set the color: text color
this code doesnt inver the menu bar though
u can basically use the browser inspector, find out what things you want to invert additionally like if u want to invert the menubar too for example and write ur own css -
i think many people just use
https://developer.mozilla.org/en-US/docs/Web/CSS/mix-blend-modemix-blend-mode: difference;
on the menu and site title. but then you need to set your menu and site title to be white, and then it uses this difference effect which is an alternative to what we're doing here.
I also made a reel about this:
I also code custom websites or custom Lay features.
šæ Email me here: šæ
info@laytheme.com
Before you post:
- When using a WordPress Cache plugin, disable it or clear your cache.
- Update Lay Theme and all Lay Theme Addons
- Disable all Plugins
- 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:
- Post a link to where the problem is
- Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
- If the problem is difficult to explain, post screenshots / link to a video to explain it