Bootstrap 4导航折叠,但不关闭

时间:2018-03-06 16:57:13

标签: navigation toggle bootstrap-4

我正在使用MAMP进行本地开发并且此切换器崩溃,但是当第二次单击时它不会关闭。如果我将代码复制/粘贴到Codepen中,则转换器按预期工作。

我看了一些类似的帖子,但他们没有解决我的问题。除了添加点击事件以强制菜单关闭之外,任何人都能解释一下解决方案吗?

这是我的代码:

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="css/style.css">
    <link rel="stylesheet" href="css/jquery.fullPage.css">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
    <script src="js/scripts.js"></script>
    <script src="js/jquery.fullPage.js"></script>       
    <script defer src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script> 
</head>

<body>

    <nav class="navbar navbar-inverse">
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#myNavbar" aria-controls="myNavbar" aria-expanded="false" aria-label="Toggle navigation">
            <span><i class="fas fa-align-left fa-2x icon-color" aria-hidden="true"></i></span>                   
        </button>
        <div class="collapse navbar-collapse" id="myNavbar">
            <ul class="navbar-nav mr-auto">
                <li class="nav-list"><a href="about.php">about</a></li>
                <li><a href="web-design.php">web design</a></li>
                <li><a href="projects.php">projects</a></li>
                <li><a href="contact.php">contact</a></li>     
            </ul>
        </div>        
    </nav>

以下是Codepen中相同代码的链接:https://codepen.io/sanzanobi/pen/QQeWxa

0 个答案:

没有答案