导航栏一次正常工作,但我进行了一些更改,因此不再起作用。当我将窗口缩小时,切换方块会出现,但是当我单击它时,什么也不会发生。

注意:导航栏在全屏模式下可以正常工作-仅在小窗口中,当我单击切换按钮时-不会出现下拉菜单

想知道是否有人知道如何解决它。

这是我的标题代码:

<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
    <div class="container">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle"
                    data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">CHRONOS LOGO</a>
        </div>
        <div class="collapse navbar-collapse">
            <ul class="nav navbar-nav">
                <li class="active"><a href="#">HOME</a></li>
                <li><a href="#">BLOG</a></li>
                <li><a href="#">ABOUT</a></li>
                <li><a href="#">CONTACT</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">SOCIAL<b class="caret"></b>
                    </a>
                    <ul class="dropdown-menu">
                        <li class="divider"></li>
                        <li><a href="#">Google+</a></li>
                        <li class="divider"></li>
                        <li><a href="#">Facebook</a></li>
                        <li class="divider"></li>
                        <li><a href="#">Twitter</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
</nav>

FOOTER :
                    <button type="submit" name="submit" id="submit"
                            class="btn btn-primary btn-lg">
                        Submit
                    </button>
                </form>
            </div>
            <?php } ?>
        </div>
        <div id="footer">
            <div class="container">
                <p class="text-muted">Place sticky footer content here.</p>
            </div>
        </div>
        <script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
        <script src="js/bootstrap.js"></script>
        <script src="regform/js/jquery.validate.js"></script>
        <script src="regform/script.js"></script>
        <script>
            addEventListener('load', prettyPrint, false);
            $(document).ready(function() {
                $('pre').addClass('prettyprint linenums');
            });
        </script>
    </body>
</html>

最佳答案

您的data-target属性值错误;相反,它应该是:

<button
    type="button"
    class="navbar-toggle"
    data-toggle="collapse"
    data-target=".navbar-collapse"> <!-- You had ID from the docs example -->
</button>

http://jsfiddle.net/fZTgH/1/

关于css - Bootstrap 3 Navbar-无法正确折叠,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/21559847/

10-13 01:34