How to create a sticky left sidebar menu using bootstrap 3?

后端 未结 3 941
生来不讨喜
生来不讨喜 2020-11-28 04:51

I want to create a left-sticky bar menu with bootstrap 3 like:

http://getbootstrap.com/getting-started/

I\'d read the given documentation http://getbootstrap

相关标签:
3条回答
  • 2020-11-28 04:52

    You can also try to use a Polyfill like Fixed-Sticky. Especially when you are using Bootstrap4 the affix component is no longer included:

    Dropped the Affix jQuery plugin. We recommend using a position: sticky polyfill instead.

    0 讨论(0)
  • 2020-11-28 04:57

    Bootstrap 3

    Here is a working left sidebar example:

    http://bootply.com/90936 (similar to the Bootstrap docs)

    The trick is using the affix component along with some CSS to position it:

      #sidebar.affix-top {
        position: static;
        margin-top:30px;
        width:228px;
      }
    
      #sidebar.affix {
        position: fixed;
        top:70px;
        width:228px;
      }
    

    EDIT- Another example with footer and affix-bottom


    Bootstrap 4

    The Affix component has been removed in Bootstrap 4, so to create a sticky sidebar, you can use a 3rd party Affix plugin like this Bootstrap 4 sticky sidebar example, or use the sticky-top class is explained in this answer.

    Related: Create a responsive navbar sidebar "drawer" in Bootstrap 4?

    0 讨论(0)
  • 2020-11-28 05:13

    I used this way in my code

    $(function(){
        $('.block').affix();
    })
    
    0 讨论(0)
提交回复
热议问题