How to add auto scroll bar vertically to cssbootstrap affix menu for smaller screens?

2.3k views Asked by At

I am using css bootstrap affix plugin as a sticky menu on my site.

I have lots of items on the menu which is not an issue on a desktop. However, when I view my site on a small laptop, the bottom half of my menu get cut off.

I need to add an auto scroll bar to the menu when the screen is small.

Here is my html code

<div class="container">
    <div class="row">

        <nav class="col-sm-3 scrollspy hidden-xs hidden-sm" id="docs-menu-column">

            <ul class="nav nav-pills nav-stacked scrollspy affix-menu" id="docs-menu" data-spy="affix">

                <li>
                  <strong>Code Generator</strong>
                  <ul class="nav">
                    <li><a href="#introduction">Introduction</a></li>
                    <li><a href="#features">Features</a></li>
                    <li><a href="#dependencies">Dependencies</a></li>
                  </ul>
                </li>

                <li>
                  <strong>Getting Started</strong>
                  <ul class="nav">
                    <li><a href="#installation">Installation</a></li>
                    <li><a href="#features">Features</a></li>
                    <li><a href="#available-commands">Available Command</a></li>
                  </ul>
                </li>

                <li>
                  <strong>How To</strong>
                  <ul class="nav">
                    <li><a href="#how-to-create-views-layout">How to create a "views-layout"</a></li>
                    <li><a href="#how-to-create-resource">How to create a resource</a></li>
                    <li><a href="#how-to-create-controller">How to create a controller</a></li>
                    <li><a href="#how-to-create-model">How to create a model</a></li>
                    <li><a href="#how-to-create-routes">How to create routes</a></li>
                    <li><a href="#how-to-create-views">How to create all standard CRUD views</a></li>
                    <li><a href="#how-to-create-create-view">How to create a "create-view"</a></li>
                    <li><a href="#how-to-create-edit-view">How to create a "edit-view"</a></li>
                    <li><a href="#how-to-create-index-view">How to create a "index-view"</a></li>
                    <li><a href="#how-to-create-show-view">How to create a "show-view"</a></li>
                    <li><a href="#how-to-create-form-view">How to create a "form-view"</a></li>
                    <li><a href="#how-to-create-migration">How to create a database migration</a></li>
                    <li><a href="#how-to-create-form-request">How to create form-request</a></li>
                    <li><a href="#how-to-create-language">How to create a language file</a></li>
                  </ul>
                </li>

                <li>
                  <strong>Fields</strong>
                  <ul class="nav">
                  <li><a href="#model-fields-overview">Overview</a></li>
                    <li><a href="#model-fields-json">Creating fields from JSON file</a></li>
                    <li><a href="#model-fields-raw">Creating fields from a raw string</a></li>
                  </ul>
                </li>

            </ul>

        </nav>


        <div class="col-md-9 large-padding-sections" id="docs-main-column">

            //Sections goes here.....
        </div>

    </div>
</div>

I tried adding style="overflow-y: auto !important;" to the <nav class="col-sm-3 scrollspy hidden-xs hidden-sm" id="docs-menu-column" but that did not work.

How can I correctly add a scroll bar vertically to the nav on the left if the screen is not high enough to show the entire affix menu?

1

There are 1 answers

2
Serg Chernata On BEST ANSWER

I think the problem is that even though you're giving it directive to scroll, there's nothing limiting the height. Try this:

height: 100vh;
overflow-y: scroll;