All geek questions in one place

    Bootstrap affix stops working after scrolling to the bottom of the page

    I have a long page with a fixed left sidebar:

    <div id="sidebar"> <ul> <li>menu 1</li> <li>menu 2</li> <li>menu 3</li> <li>menu 4</li> <li>menu 5</li> <li>menu 6</li> <li>menu 7</li> </ul> </div> 

    and js for affix :

     $("#sidebar").affix({offset: {top: 0, bottom:420} }); 

    I also have a footer with height:390px . When I first scroll the bottom of the page and scroll the sidebar, it returns to its first position (at the top of the page), and it is no longer with position:fixed . It has a built-in position:relative style added with Bootstrap JS. When I scroll up, I see a class changed to affix-top . At any other position on the scroll page, the affix class, even if it is at the bottom of the page and sidebar with position:relative . If I use only:

     $("#sidebar").affix({offset: {top: 0} }); 

    without bottom , it works fine, but I need bottom , due to footer .

    Where could the problem be?

    +7
    html css twitter-bootstrap twitter-bootstrap-3 affix
    gdfgdfg Mar 29 '17 at 18:42
    source share
    1 answer

    Since the docs suggest adding position: absolute to solve this problem, by .affix-bottom apparently, using position: absolute value of .affix-bottom .

    So you need CSS:

     #sidebar.affix-bottom { position: absolute; } 

    Bootply

    +6
    Zac Jul 31 '17 at 18:46
    source share

    Source: https://habr.com/ru/post/1266086/

    More articles:

    • REST request memory leak when no character is returned in the header - rest
    • Multiple Flyway metadata tables in one schema - postgresql
    • Error handling with Observables in Angular 2 - angular
    • TypeScript enumeration into an array of objects - javascript
    • How to split a sequence in F # based on another sequence along an idiomatic path - f #
    • How to call asynchronous methods in Hangfire? - c #
    • SilverStripe random order for ArrayList () - arraylist
    • what are the circumstances of using .Wait () when calling async methods - c #
    • What is the Pythonic way to remove duplicate duplicates in a list, but allow triplets / more? - python
    • undefined: PySlice_AdjustIndices when importing PyTorch - python

    All Articles

    Geek Questions | 2019