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
633 views
in Technique[技术] by (71.8m points)

Bootstrap 5 Navbar Collapse function Inside Dropdown function (Mobile) not working

This question is for Bootstrap 5. I've created a navbar that allows you to click on the first link (Open First Level) to open the dropdown and inside it, I have another collapse function (Open Second Level) which supposed to allow the user to click to open another set of links.

The issue I'm having is that when I try to click on the Open Second Level link, the navbar actually closes rather than remain open and show the Open Second Level sub links.

How can I open the second collapse link without the first one closes?

You can refer to the scripts here:-

        <nav class="navbar navbar-expand-lg">
        <div class="container-fluid">
            <a class="navbar-brand" href="#">Nav Logo</a>
            <button class="navbar-toggler hamburger hamburger--spring" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                <div class="hamburger-box">
                    <div class="hamburger-inner"></div>
                </div>
            </button>

            <div class="collapse navbar-collapse" id="navbarSupportedContent">
                <ul class="navbar-nav ms-auto align-self-center">

                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                            Open First Level
                        </a>
                        <div class="dropdown-menu w-100 shadow" aria-labelledby="navbarDropdown">
                            <div class="d-lg-flex p-4 p-lg-0">
                                <div class="flex-grow-1 nav-sku-container">
                                    <div class="row">
                                        <div class="col-md-3">
                                            <div class="nav-sku-block">
                                                <div class="title-sm">
                                                    <a class="" data-bs-toggle="collapse" href="#collapseToilet" role="button" aria-expanded="false" aria-controls="collapseToilet">
                                                        Open Second Level
                                                    </a>
                                                </div>
                                                <div class="collapse open-d" id="collapseToilet">
                                                    <ul>
                                                        <li><a href="">Coupled</a></li>
                                                        <li><a href=""> Coupled</a></li>
                                                        <li><a href=""> Coupled</a></li>
                                                        <li class="viewall"><a href="">View All</a></li>
                                                    </ul>
                                                </div>

                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

https://jsfiddle.net/0tnrfj6q/1/

Thanks for all your help in advance!

question from:https://stackoverflow.com/questions/66049433/bootstrap-5-navbar-collapse-function-inside-dropdown-function-mobile-not-worki

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

1 Reply

0 votes
by (71.8m points)
Waitting for answers

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

...