Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap Navbar list items/links not showing

I am learning to use Bootstrap and playing with components, specifically the navbar.

My links/list items aren't showing. I have copied code directly from Bootstrap. I'm hoping someone could please explain what I'm missing.

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>NavBar</title>

    <!-- bootstrap css -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">
</head>    
<body>      
    <nav class="navbar navbar-toggleable-md navbar-light bg-faded">
        <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>
        <a class="navbar-brand" href="#">Navbar</a>
        <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
            <div class="navbar-nav">
                <a class="nav-item nav-link active" href="#">Home <span class="sr-only">(current)</span></a>
                <a class="nav-item nav-link" href="#">Features</a>
                <a class="nav-item nav-link" href="#">Pricing</a>
                <a class="nav-item nav-link disabled" href="#">Disabled</a>
            </div>
        </div>
    </nav>      
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/js/bootstrap.min.js" integrity="sha384-vZ2WRJMwsjRMW/8U7i6PWi6AlO1L79snBrmgiDpgIWJ82z8eA5lenwvxbMV1PAh7" crossorigin="anonymous">
    </script>   
</body>
like image 647
DumbDevGirl42069 Avatar asked Mar 10 '17 00:03

DumbDevGirl42069


3 Answers

In Bootstrap 4, the navbar-expand-* class is needed to show the horizontal navbar, otherwise it will collapse into it's mobile state.

Make sure you've referenced it properly in the Codepen as https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css

Or, use Codeply, and it will include the all the relevant libraries for you: Bootstrap 4 on Codeply

Here's the Navbar with Bootstrap 4.0.0: http://www.codeply.com/go/SmEyy7rg5S

<nav class="navbar navbar-expand-md navbar-light bg-faded">
    <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>
    <a class="navbar-brand" href="#">Navbar</a>
    <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
        <div class="navbar-nav">
            <a class="nav-item nav-link active" href="#">Home <span class="sr-only">(current)</span></a>
            <a class="nav-item nav-link" href="#">Features</a>
            <a class="nav-item nav-link" href="#">Pricing</a>
            <a class="nav-item nav-link disabled" href="#">Disabled</a>
        </div>
    </div>
</nav>

Related: Disable responsive navbar in bootstrap 4

like image 52
Zim Avatar answered Nov 18 '22 17:11

Zim


your reference to their css file is not what is listed on their website. use the following:

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

your java script file is also not what is listed:

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

here is where you can find the latest links to their most up-to-date CDN's: http://getbootstrap.com/getting-started/

you are have probably copied that from an experimental place. (it says alpha within the file name so there are more than likely some bugs)

like image 26
Jeremy Buentello Avatar answered Nov 18 '22 17:11

Jeremy Buentello


It looks like you are using the alpha version of bootstrap. This version may contain a bug. You might want to use the latest stable version. This answer has the links to the correct css and js files for version 3.3.7. If bootstrap is updated after this answer, you can download the latest version at http://getbootstrap.com/getting-started/. Hope this helps!

Albert

like image 1
asportnoy Avatar answered Nov 18 '22 16:11

asportnoy