简体   繁体   中英

How to make collapsible sidebar sticky?

I am trying to make the sidebar in this example sticky when scrolling, for both situations (when you are using a big display and the sidebar is visible, as well as on mobile devices when you toggle the menu manually). I have followed various similar answers on this site but I could not apply them to my particular situation. For example, the following did not help:

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

#sidebar.affix {
    position: fixed;
    top:70px;
    width:228px;
}

Any ideas how to do it? Thanks!

adding

#sidebar .nav {
    width: 95%;
    position:fixed;
}

works for me

fiddle: http://jsfiddle.net/PrakharThakur/afrbbsh3/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM