Menu on top after scrolling
-
Hi,
If you want to get you menu in top even when you scroll you can add the next script into your graphene-child and the styles in your stylesheet.
function tjintjinStart() { jQuery("nav").attr("id", "tjintjinNav"); tjintjinXY = getCoords(document.getElementById("tjintjinNav")); jQuery(window).on('scroll', function(){ if ( (jQuery(window).scrollTop() > tjintjinXY.top) && !jQuery("#tjintjinNav").hasClass("tjintjinNav") ) { jQuery("#tjintjinNav").addClass("tjintjinNav"); } else if ( jQuery(window).scrollTop() < tjintjinXY.top && jQuery("#tjintjinNav").hasClass("tjintjinNav") ) { jQuery("#tjintjinNav").removeClass("tjintjinNav"); } }); } function getCoords(tjintjinElement) { var box = tjintjinElement.getBoundingClientRect(); var body = document.body; var docEl = document.documentElement; var clientTop = docEl.clientTop || body.clientTop || 0; var clientLeft = docEl.clientLeft || body.clientLeft || 0; var top = (box.top - clientTop); var left = box.left - clientLeft; return { left: Math.round(left), top: Math.round(top), width: Math.round(tjintjinElement.offsetWidth), height: Math.round(tjintjinElement.offsetHeight), boxTop: Math.round((tjintjinElement.offsetTop)*1+jQuery(window).scrollTop()) }; } document.onload = tjintjinStart(); /* styles for stylesheet */ /* .tjintjinNav { position: fixed; width: 100%; max-width: 1280px; top: 0px; z-index: 1000; } .container { width: 100%; max-width: 1280px; } */
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Menu on top after scrolling’ is closed to new replies.