Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
774 views
in Technique[技术] by (71.8m points)

html - bootstrap 4 making dropdown scrollable

I have a problem with my drop down menu on smaller devices. i cannot make it scroll able when i tried the solution here (that is overflow:auto/ overflow-y:scroll) it's not working even if i use !important. What i'm able to scroll was my main page even if the drop down is open. enter image description here

<nav class="navbar navbar-toggleable-sm ">
    <button class="navbar-toggler navbar-toggler-right main-navbar-toggler" type="button" data-toggle="collapse" data-target="#main-nav-collapse" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
        <span class="fa fa-bars"></span>
    </button>
    <a class="navbar-brand animation" data-animation ="fadeInLeft" href="#"><img src="/093017/img/logo-tmi.png" alt="logo"/></a>
    <div class="collapse navbar-collapse" id = "main-nav-collapse" >
        <ul class="nav navbar-nav navbar-main mr-auto mt-2 mt-md-0 animation" data-animation = "fadeInRight">
            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false">Vehicles</a>
                <div class="dropdown-menu default-menu main-menu sm-main-menu animation" data-animation = "fadeIn">
                    <!-- Nav tabs -->
                    <div class="sm-main-nav" >
                        <a class="dropdown-item" href="#">Cars</a><hr>
                        <a class="dropdown-item" href="#">Vans & Pickup</a><hr>
                        <a class="dropdown-item" href="#">SUVs & Crossover</a><hr>
                        <a class="dropdown-item" href="#">MPVs</a><hr>
                        <a class="dropdown-item" href="#">Hybrid</a><hr>
                        <a class="dropdown-item" href="#">Performance</a>
                    </div>
                </div>
            </li>
            <li class="nav-item">
                <a class="nav-link " href="#">Owners</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Shop</a>
            </li>
            <li class="nav-item">
                <a class="nav-link " href="#">Promotions</a>
            </li>
        </ul>
    </div>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

just you can use @media in your css

@media (max-width: 500px) {
    .dropdown-menu{
          height:200px;
          overflow-y:auto;
       }
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...