Logo Transparent to Solid

Hi,

I’m using the following to make my header transition from transparent to solid when scrolling.
I was wondering if you have any suggestions on how to modify it so that my Logo appears once the header is solid.

Any suggestions would be greatly appreciated!

jQuery(document).ready(function($){
  $('.x-navbar-fixed-top').css("background-color", "transparent");
  $(window).scroll(function(){
   if ($(this).scrollTop() > 400) {
    $('.x-navbar-fixed-top').css("background-color", "rgba(255,255,255,0.99)").css("transition","0.3s ease-in-out ");
   } else if ($(this).scrollTop() > 300) {
    $('.x-navbar-fixed-top').css("background-color", "rgba(255,255,255,0.75)").css("transition","0.3s ease-in-out ");
   } else if ($(this).scrollTop() > 200) {
    $('.x-navbar-fixed-top').css("background-color", "rgba(255,255,255,0.5)").css("transition","0.3s ease-in-out ");
   } else if ($(this).scrollTop() > 100) {
    $('.x-navbar-fixed-top').css("background-color", "rgba(255,255,255,0.35)").css("transition","0.3s ease-in-out ");
   } else {
    $('.x-navbar-fixed-top').css("background-color", "transparent").css("transition","0.3s ease-in-out ");
   }
  });
});

Hi There,

Ideally, we will hide the logo on the website loads. When we scroll down over 400, the logo will be shown. Please update your custom JS to this:

jQuery(document).ready(function($){

	$('.x-brand').hide();
	$('.x-navbar-fixed-top').css("background-color", "transparent");

	$(window).scroll(function(){
		if ($(this).scrollTop() > 400) {
			$('.x-brand').show();
			$('.x-navbar-fixed-top').css("background-color", "rgba(255,255,255,0.99)").css("transition","0.3s ease-in-out ");
		} else if ($(this).scrollTop() > 300) {
			$('.x-navbar-fixed-top').css("background-color", "rgba(255,255,255,0.75)").css("transition","0.3s ease-in-out ");
		} else if ($(this).scrollTop() > 200) {
			$('.x-navbar-fixed-top').css("background-color", "rgba(255,255,255,0.5)").css("transition","0.3s ease-in-out ");
		} else if ($(this).scrollTop() > 100) {
			$('.x-navbar-fixed-top').css("background-color", "rgba(255,255,255,0.35)").css("transition","0.3s ease-in-out ");
		} else {
			$('.x-brand').hide();
			$('.x-navbar-fixed-top').css("background-color", "transparent").css("transition","0.3s ease-in-out ");
		}
	});
});

Hope that helps and thank you for understanding.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.