Tagged: x
-
AuthorPosts
-
January 6, 2017 at 2:31 am #1318536
c1sParticipantHi,
I already found a nice code which adds a shadow to the navbar only when scrolled:CSS:
.x-navbar.shadow { -webkit-box-shadow: 0px 3px 5px -2px #6b6b6b; -moz-box-shadow: 0px 3px 5px -2px #6b6b6b; box-shadow: 0px 3px 5px -2px #6b6b6b; }JQUERY:
jQuery(document).ready(function($){ $(window).scroll(function(){ if ($(this).scrollTop() > 0) { $('.x-navbar-fixed-top').css("background-color", "rgba(255,255,255,1.0"); $( '.x-navbar' ).addClass( 'shadow' ); } else { $('.x-navbar-fixed-top').css("background-color", "rgba(255,255,255,0.0"); $( '.x-navbar' ).removeClass( 'shadow' ); } }); });I would like to refine that code now, so that the navbar shadow appears only at that point of scrolling down, when the navbar has reached the top of the page.
Thanks for your help!!!
January 6, 2017 at 2:33 am #1318537
c1sParticipantThis reply has been marked as private.January 6, 2017 at 3:09 am #1318570
Rue NelModeratorHello There,
Thanks for writing in! To resolve this issue, refining the shadow of the navbar, please have the JS code updated and make use of this code instead:
jQuery(document).ready(function($){ $(window).scroll(function(){ if ($(this).scrollTop() > 200) { $('.x-navbar-fixed-top').css("background-color", "rgba(255,255,255,1.0"); $( '.x-navbar' ).addClass( 'shadow' ); } else { $('.x-navbar-fixed-top').css("background-color", "rgba(255,255,255,0.0"); $( '.x-navbar' ).removeClass( 'shadow' ); } }); });I just change the
> 0to> 200. This is the position of the navbar as soon as you scroll the page.We would loved to know if this has work for you. Thank you.
January 6, 2017 at 3:22 am #1318582
c1sParticipantThat has worked perfectly!!! Thanks very much!! 🙂
January 6, 2017 at 3:37 am #1318605
Rue NelModeratorHello There,
You’re welcome! Thanks for letting us know that it has worked for you.
If you need anything else we can help you with, don’t hesitate to open another thread.Best Regards.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1318536 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
