I am trying to create a sticky menu using CSS Bootstrap affix and list-group .
I manage to get most of the work, except when the user scrolls down.
When the user scrolls down, the menu seems to occupy the entire page.
I tried to configure it using data attributes
using something like this
<div class="container"> <div class="row"> <div class="col-md-3" id="leftCol"> <div data-spy="affix"> <div class="list-group list-group-root well"> <a class="list-group-item" href="#introduction">Introduction</a> <a class="list-group-item" href="#features">Features</a> <a class="list-group-item" href="#dependencies">Dependencies</a> </div> </div> </div> <div class="col-md-9" id="mainCol"> Some long text for the body along with some tables. </div> </div> </div>
But the data attribute did not make the menu button! he just kept it on top.
So, I tried using JS to do this job like this.
$(function(){ $('#leftCol').affix({ offset: { top: 100, bottom: function () { return (this.bottom = $('.footer').outerHeight(true)) } } }); });
I created jsFiddle to show you the current behavior.
How can I fix this affix , so when the user scrolls through the menu, maintains the same form?
source share