简体   繁体   English

如何在Bootstrap中制作粘性侧边栏?

[英]How to make a sticky sidebar in Bootstrap?

How can I make a sticky sidebar like this one, cpmta.org, but with Bootstrap? 如何使用Bootstrap制作像这样的粘性侧边栏cpmta.org? I am having a hard time trying to do this... 我很难做到这一点...

It's already there in Bootstrap and it is called Bootstrap Affix. 它已经存在于Bootstrap中,称为Bootstrap Affix。 This is the code: 这是代码:

<script type="text/javascript">
$(document).ready(function () {
    $("#myNav").affix({
        offset: { 
            bottom: 195 
        }
    });
});
</script>

And you can add the data-spy as well: 您还可以添加data-spy

<ul class="nav nav-tabs nav-stacked" data-spy="affix" data-offset-top="195">
    <li class="active"><a href="#one">Section One</a></li>
    <li><a href="#two">Section Two</a></li>
    <li><a href="#three">Section Three</a></li>
</ul>

For more information, kindly follow the instructions from: 有关更多信息,请遵循以下说明:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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