I'm using Sticky.js (http://stickyjs.com) to affix my page nav once it reaches to top of the screen. Works well so far, except for that there seems to be a z-index or transparency issue once the stickiness is triggered. The content passes too visibly beneath the fixed nav, during which the nav links are not reliably selectable.
Here's a quick screenflow to demonstrate: https://web.archive.org/save/cl.ly/StqJ
My site: https://livingibogaine.squarespace.com/detox/
HTML:
/* jquery */ <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
/* sticky script */ <script type="text/javascript" src="https://cdn.jsdelivr.net/jquery.sticky/1.0.0/jquery.sticky.min.js"></script>
<script type="text/javascript">
$(window).load(function(){
$("#page-nav").sticky({ topSpacing: 0 });
});
</script>
<ul id="page-nav">
<a href="#chapter-1"><li>Iboga Ceremony</li></a>
<a href="#chapter-2"><li>Clinical Detox</li></a>
<a href="#chapter-3"><li>Medical Standards</li></a>
<a href="#canvas-wrapper"><li>Top ↑</li></a>
</ul>
CSS:
#page-nav {
/* structural stuff */
position: absolute; top: -40px; left: 0; right: 0;
padding: 0 1500px; margin: 0 -1500px;
/* non-essentials */
text-align: center; font-size: 16px; line-height: 3em;
list-style: none; background-color: #A47938;
}
Your navigation and content are both contained in divs, which have the class .sqs-block
. This class has set z-index: 1
. The problem is, z-index
is relative to the parent, so when you apply a z-index of 999 to your navigation, this will have no apparent effect. The solution is to override the z-index for your navigations container. Given your current markup, this CSS will do it:
#content .row:first-child .sqs-block { z-index: 999; }
Alternatively, you can do this with jQuery:
$('#page-nav').closest('.sqs-block').css('z-index', '999');