简体   繁体   English

当我单击可折叠菜单时,为什么它没有展开?

[英]Why doesn't my collapsible menu expand when I click on it?

Don't know what I am missing from my code. 不知道我的代码中缺少什么。 When I shrink the size the 3 bars show up but when I click on them they don't toggle the menu. 当我缩小尺寸时,会显示3条,但是当我单击它们时,它们不会切换菜单。

<!DOCTYPE html>
<html>
<head>
    <title>Prototype</title>
    <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
</head>
<body>
    <nav class="navbar navbar-default" role="navigation">  
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-  target="#main-nav">
                    <span class="sr-only">Toggle Navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a href="#" class="navbar-brand">Brand</a>
            </div>

            <!-- Collect nav links, forms, and other content into div for toggle -->
            <div class="collapse navbar-collapse" id="main-nav">
                <ul class="nav navbar-nav">
                    <li class="active"><a href="#">Link</a></li>
                    <li><a href="#">Link</a></li>
                    <li><a href="#">Link</a></li>
                    <li><a href="#">Link</a></li>
                </ul>
            </div>
        </div>
    </nav> 
    <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
</body>
</html>

here is the code on jsfiddle: http://jsfiddle.net/5SBqQ/ 这是jsfiddle上的代码: http : //jsfiddle.net/5SBqQ/

Bootstrap requires jQuery. Bootstrap需要jQuery。 Adding: 添加:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

before you add bootstrap should fix the issue. 在添加引导程序之前,应先解决此问题。

http://jsfiddle.net/4LWQv/2/ (Removed the script and link tags for jsfiddle) http://jsfiddle.net/4LWQv/2/ (已删除jsfiddle的脚本和链接标签)

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

相关问题 React 可折叠菜单组件,当我单击类别标题时应该展开但不会显示子链接 - React collapsible menu component that should expand when I click on a category title but won't show the children links 为什么我的可折叠按钮不折叠? - Why my collapsible button doesn’t collapse? 使用f:ajax(JSF)更新后,为什么我的Materialize可折叠菜单不起作用? - Why is it that my Materialize collapsible menu doesn't work after updating with f:ajax (JSF)? 为什么我的下拉菜单在点击时不显示? - Why doesn't my dropdown menu show on click? 尝试创建手风琴菜单,当我点击问题的标题时,答案不会出现或崩溃,为什么会这样? - Trying to create an accordion menu and when I click on the title of the question, the answer doesn't appear or collapse, why is this? 单击导航菜单后,为什么下拉菜单在我的导航栏中不起作用? - Why isn't the dropdown menu working in my navbar when I click it? 单击切换按钮时折叠菜单不会关闭 - Collapse menu doesn't close when I click on toggler button 当我点击时,汉堡菜单没有关闭 - hamburger menu doesn't close when i click 当我在 hover 上方时,为什么我的下拉菜单不可见? - Why doesn't my drop-down menu stay visible when I hover over it? 为什么单击菜单图标时我的正常导航栏消失了 - Why is my normal navbar disappearing when I click on the menu icon
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM