Bootstrap bottom affix issue

322 views Asked by At

I'm implementing bottom affix and when the page has a scroll bar the feature seems to work fine the issue is when a scroll bar isn't needed things seem wrong.

My bottom navigation is pinned to the bottom of the screen (bottom:0:) until it is 160px from page edge at which point it docks just above the footer as expected - going from AFFIX to AFFIX BOTTOM class

My issue is when the page loads maximised (I have a large resolution) and doesn't need scrollbars the affix bar is hidden until you click anywhere on the page at which point it displays where you expect it - click again anywhere and it hides!!!

From inspecting DOM I can see on page load (without scrollbars) the affix starts with a class of AFFIX and therefore is positioned bottom:0 due to my css for affix state (its hidden cos its behind my footer and out of sight) when you click the page it toggles to AFFIX-BOTTOM and comes into view because it obeys the requirements of affix-bottom.

I think the key to this is why is it applying a class of AFFIX in this scenario? clicking the page causes it to correct itself but thats very strange and shouldnt be needed.

.affix-bottom {
    position: absolute;

}

.affix{
    bottom:0px;
}

.affix-top {
    top:0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<div class="row" data-spy="affix" data-offset-bottom="160">
    <div class="col-xs-6">
        <asp:Button ID="btnPrev" UseSubmitBehavior="true" CssClass="btn btn-default btn-lg" runat="server" Text="Previous Step""></asp:Button>
    </div>
    <div class="col-xs-6 text-right">
        <asp:Button ID="btnNext" UseSubmitBehavior="true" CssClass="btn btn-lg" runat="server" Text="Next Step"></asp:Button>
    </div>
</div>

0

There are 0 answers