简体   繁体   中英

My bootstrap nav dropdown for small screens is not working

My nav dropdown button for smaller screens (phones and tablets) is not working. I have included the JS files but its still not working. Can anyone help determine why this is not wanting to connect with my js files.

HTML

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
    <link rel="stylesheet" type="text/css" href="css/bootstrap.mini.css">
    <link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<!-- Header -->
    <header>
        <nav class="navbar navbar-default navbar-fixed">
            <div class="container">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="index.html">AffAttraction</a>
                </div>
                <div class="collapse navbar-collapse" id="myNavbar">
                <ul class="nav navbar-nav">
                    <li><a href="index.html">Home</a></li>
                    <li><a href="advertisers.html">Advertisers</a></li>
                    <li><a href="publishers.html">Publishers</a></li>
                    <li><a href="blog.html">Blog</a></li>
                    <li><a href="about.html">About Us</a></li>
                    <li><a href="contact.html">Contact Us</a></li>
                </ul>
                <form class="navbar-form navbar-right">
                <input type="email" name="email" class="form-control" placeholder="Email" required="">
                <input type="password" name="password" class="form-control" placeholder="Password" required="">
                <button type="submit" class="btn btn-green">Login <span class="glyphicon glyphicon-log-in"></span></button>
                </form>
                </div>
            </div>
        </nav>
    </header>
<!-- Header -- >
<!-- Showcase -->
    <div id="showcase">
        <div class="container">
            <div class="row">
                <div class="col-sm-12">
                <h1><span class="highlight">Performance</span> Based Marketing</h1>
                <p>Do you have traffic? Let us help you monetize and profit from your websites, apps, games, blogs, and more!</p>
                </div>
            </div>
        </div>
    </div>
<!-- Showcase -->
<script src="js/bootstrap.js"></script>
<script src="js/bootstrap.mini.js"></script>
</body>
</html>

I have included it at the top under my CSS links if you think that could be a problem. I also tried putting it under the body tag and the html tag. I am lost on what to do. Those files do exist!

I tried to run your code, replacing your local bootstrap stylesheets with the CDN version. When I loaded it, I crashed because jQuery was missing. After adding jQuery inside the head, it worked:

<script src="http://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>

If you want to connect the Bootstrap CSS and JS files on your HTML , you can easily do that with Bootstrap CDN.

Add this this to your <head> as Bootstrap Stylesheet https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css

And this to your <body> as Bootstrap JavaScript link https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js

Also add JQuery for Bootstrap to work properly https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM