I am trying to mimic IG's navbar at some point.
I am trying to center all of my elements: logo, search bar and avatar icon and make them all have spaces on the center of the screen like you see here:
However even though I used col-push it doesn't change the behavior of my grids:
<div class="container-fluid">
<div class="row no-gutter">
<div class="col-lg-12 no-space">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="col-lg-4">
<a class="navbar-brand white">LifeShot</a>
</div>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarNavDropdown"
aria-controls="navbarNavDropdown"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<div class="col-lg-4">
<input
class="form-control mr-sm-2"
type="search"
placeholder="Search"
aria-label="Search"
/>
</div>
<div class="col-lg-4">
<i class="fa fa-user-o fa-lg white" aria-hidden="true"></i>
</div>
</div>
</nav>
</div>
</div>
</div>
Here's the jsfiddle.
Any idea what am I missing here?
.body {
width: 100%;
}
.white {
color: #fff !important;
}
.no-space {
padding: 0;
margin: 0;
}
.align-center {
text-align: center;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<div class="row no-gutter">
<div class="col-lg-12 no-space">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="col-lg-4 col-md-4 col-sm-4">
<a class="navbar-brand white">LifeShot</a>
</div>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarNavDropdown"
aria-controls="navbarNavDropdown"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<div class="row no-gutter">
<div class="col-lg-6 col-md-6 col-sm-6 align-center">
<input
class="form-control mr-sm-2"
type="search"
placeholder="Search"
aria-label="Search"
/>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 align-center">
<i class="fa fa-user-o fa-lg white" aria-hidden="true"></i>
</div>
</div>
</div>
</nav>
</div>
</div>
</div>
You are doing it wrong. You should have only "col-" classes under "row".
Here you have button in between.
You should have 12 columns in total for each row.
So following should be the structure:
<div class="row">
<div class="col-2">
<div class="row">
<div class="col-6">Logo</div>
<div class="col-6">Text</div>
</div>
</div>
<div class="col-8"><!--Empty Space--></div>
<div class="col-2">
<div class="row">
<div class="col-4">icon1</div>
<div class="col-4">icon2</div>
<div class="col-4">icon3</div>
</div>
</div>
</div>
Just remove the unwanted row and container in your code. Move the mobile collapse button near the navbar. I hope this solution will be helpful.
.body {
width: 100%;
}
.white {
color: #fff !important;
}
.no-space {
padding: 0;
margin: 0;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"></script>
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
LifeShot
<div class="col-lg-4">
<input class="form-control" type="search" placeholder="Search" aria-label="Search" />
</div>
<div class="col-lg-4 text-md-right">
<i class="fa fa-user-o fa-lg white" aria-hidden="true"></i>
</div>
</div>
</nav>
I guess that nav as is is row at all. So you don't need to add it again. Maybe i'm wrong but this is working for me :
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container-fluid">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<div class="col-lg-12 col">
<div class="row">
<div class="col-lg-4 col">
Here comes logo
</div>
<div class="col-lg-4 col">
<input placeholder="Search">
</div>
<div class="col-lg-4 col text-right">
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarNavDropdown"
aria-controls="navbarNavDropdown"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
</div>
</div>
</div>
</nav>
You can try this much simpler way:
<link rel="stylesheet" type="text/css" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.css">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark justify-content-around">
<a class="navbar-brand" href="#">LifeShot</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse flex-grow-0" id="navbarNavDropdown">
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
</form>
<ul class="navbar-nav">
<li class="nav-item">
<i class="fa fa-user-o fa-lg" aria-hidden="true" style="color: #fff;"></i>
</li>
</ul>
</div>
</nav>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"></script>
<script type="text/javascript" src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"></script>
I cleared your code a little. Dont put the NavBar in a Container, just in the body tag.
Then you can change the Container widht in the navbar, to make the space between your navbar-brand and your search box smaller.
<nav class="navbar navbar-expand-lg navbar-dark bg-dark ">
<div class="container w-50">
<a class="navbar-brand white">LifeShot</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNavDropdown">
<form class="form-inline my-2 my-md-0 ml-auto">
<input
class="form-control mr-sm-2"
type="search"
placeholder="Search"
aria-label="Search"
/>
</form>
<i class="fa fa-user-o fa-lg white" aria-hidden="true"></i>
</div>
</div>
</nav>
Now you can use the fix bootstrap "width-changer-classes" like w-25,w-50,w-75 (25%, 50%, 75% width) etc. or you can write your own width class like:
.costum-w-80 {
width: 80%;
}
And now just replace custom-w-80 with w-50.
Related
Is it even possible to do it? I would appreciate any directions. I would like to stay within Bootstrap framework
Text blocks should be aligned with the navigation border left and right:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/css/bootstrap.min.css" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container ">
<a class="navbar-brand" href="#">
<img data="data-inject-svg" src="https://via.placeholder.com/50" alt="logo">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse float-end" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link" href="#">1</a>
</li>
<li class="nav-item">
<a class="nav-link">2</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid ">
<div class="row justify-content-start reflections">
<div class="col-6 ">
wide text
</div>
<div class="col-4 col-offset-2">
<div class="text">
text
</div>
</div>
</div>
<div class="row justify-content-start reflections">
<div class="col-4 offset-2 ">
text
</div>
<div class="col-6 ">
wide text
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>
alright, I think this is the answer -->
image
<div class="container-fluid ">
<div class="row ">
<div class="col-8 offset-2 col-offset-2">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
your navbar
</nav>
</div>
</div>
</div>
I want to place the place the search bar in the middle of the navigation bar. Not able to make out in which particular class of bootstrap should i make the changes.
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta2/dist/js/bootstrap.bundle.min.js" integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/#popperjs/core#2.6.0/dist/umd/popper.min.js" integrity="sha384-KsvD1yqQ1/1+IA7gi3P0tyJcT3vR+NdBTt13hSJ2lnve8agRGXTTyNaBYmCR/Nwi" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta2/dist/js/bootstrap.min.js" integrity="sha384-nsg8ua9HAw1y0W1btsyWgBklPnCUAFLuTMS2G72MMONqmOymq585AcH49TLBQObG" crossorigin="anonymous"></script>
<link rel="stylesheet" href="/home/home/Desktop/JAIN MEDICOS/css/master.css">
<title>Title</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">Jain Medicos</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
</li>
</ul>
**<form class="d-flex">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search" size="90">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>**
</div>
</div>
</nav>
</body>
</html>
Add mx-auto class to the form.
And if you are not using this code:
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
</li>
</ul>
Then remover it because you will see that it is affecting the position of the search input.
Your link and script tags were not in correct position so I have tweaked it a little bit.
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<link rel="stylesheet" href="/home/home/Desktop/JAIN MEDICOS/css/master.css">
<title>Title</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">Jain Medicos</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
</li>
</ul>
<form class="d-flex mx-auto">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search" size="90">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</div>
</nav>
</body>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.0.0-beta2/dist/js/bootstrap.bundle.min.js" integrity="sha384-b5kHyXgcpbZJO/tY9Ul7kGkf1S0CWuKcCD38l8YkeH8z8QjE0GmW1gYU5S9FOnJ0" crossorigin="anonymous"></script>
</html>
Check it in action on Codepen: https://codepen.io/manaskhandelwal1/pen/poNNpOR?editors=1000
Use mx-auto on the form and remove the me-auto from the navbar-nav...
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<a class="navbar-brand" href="#">Jain Medicos</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mb-2 mb-lg-0">
<li class="nav-item">
</li>
</ul>
<form class="d-flex mx-auto">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search" size="90">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</div>
</nav>
Demo
I have created two navigation bars, where the one below is included in the dropdown toggle icon when screen becomes small. On the first navigation bar, I have two items pushed to the far right. When I resize the screen, I can see the hamburger icon; however, these items become stacked on each other. I know that if I use navbar-expand the items will be displayed properly, but then the hamburger icon won't be shown.
This is my code:
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<!-- First navigation bar -->
<div class="container-fluid" style="margin-top: 0px;">
<nav class="navbar navbar-light navbar-expand-sm bg-white">
<div id="burger">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation" style="border: none; background: none; outline:none;">
<span class="navbar-toggler-icon"></span>
</button>
</div>
<a class="navbar-brand" href="#"> <img src="assets/logo/logo.PNG" width="160" height="60" class="d-inline-block align-top" alt=""> </a>
<div class="navbar-nav ml-auto"> <!-- the items on the right -->
<div class="dropdown item" style="margin-top: 12px; margin-right: 10px;">
<button class="no-style dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="notification_button">
<span class="icon icofont-notification text-secondary"></span>
<div>
<span class="badge badge-danger badge-sm">6</span>
</div>
</button>
</div>
<div class="dropdown item">
<button class="no-style dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" data-offset="0, 10" style="border: none; background: none; outline:none;">
<span class="d-flex align-items-center">
<img src="/assets/content/user.jpg" style="border-radius: 500px!important;" alt="" width="40" height="40" class="mr-1"> <i class="icofont-simple-down"></i>
</span>
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton" x-placement="bottom-end">
<span class="icon icofont-ui-home"></span> Edit account
<span class="icon icofont-ui-user"></span> User profile
<span class="icon icofont-ui-calendar"></span> Calendar
<span class="icon icofont-ui-settings"></span> Settings
<span class="icon icofont-logout"></span> Log Out
</div>
</div>
</div>
</nav>
</div>
<!-- Second navigation bar -->
<div class="container-fluid" style="margin-top: -10px;">
<nav class="navbar navbar-light navbar-expand-sm">
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-item nav-link" href="/link-1">link</a>
<a class="nav-item nav-link" href="/link-2">link</a>
<a class="nav-item nav-link" href="/link-3">link</a>
</div>
</div>
</nav>
</div>
How can I display the hamburger and the two items on the right without having them stacked on each other?
They are stacked on each other because their container has the navbar-nav class apllied, which contains the property "flex-direction:column", you should apply "flex-direction:row" instead in the css, or the class "flex-row" in the html:
<div class="navbar-nav ml-auto flex-row">
</div>
Your problem is that the style
.navbar-expand-sm .navbar-nav {
-ms-flex-direction: row;
flex-direction: row;
}
in _navbar.scss is limited to a min-width of 576px using a media query.
In order to achieve your goal you can apply the style manually resulting in your items not get stacked anymore, like this:
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet"/>
<style>
#right-navbar {
-ms-flex-direction: row;
flex-direction: row;
}
</style>
<!-- First navigation bar -->
<div class="container-fluid" style="margin-top: 0px;">
<nav class="navbar navbar-light navbar-expand-sm bg-white">
<div id="burger">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation" style="border: none; background: none; outline:none;">
<span class="navbar-toggler-icon"></span>
</button>
</div>
<a class="navbar-brand" href="#"> <img src="assets/logo/logo.PNG" width="160" height="60" class="d-inline-block align-top" alt=""> </a>
<div id="right-navbar" class="navbar-nav ml-auto"> <!-- the items on the right -->
<div class="dropdown item" style="margin-top: 12px; margin-right: 10px;">
<button class="no-style dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" id="notification_button">
<span class="icon icofont-notification text-secondary"></span>
<div>
<span class="badge badge-danger badge-sm">6</span>
</div>
</button>
</div>
<div class="dropdown item">
<button class="no-style dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" data-offset="0, 10" style="border: none; background: none; outline:none;">
<span class="d-flex align-items-center">
<img src="/assets/content/user.jpg" style="border-radius: 500px!important;" alt="" width="40" height="40" class="mr-1"> <i class="icofont-simple-down"></i>
</span>
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton" x-placement="bottom-end">
<span class="icon icofont-ui-home"></span> Edit account
<span class="icon icofont-ui-user"></span> User profile
<span class="icon icofont-ui-calendar"></span> Calendar
<span class="icon icofont-ui-settings"></span> Settings
<span class="icon icofont-logout"></span> Log Out
</div>
</div>
</div>
</nav>
</div>
<!-- Second navigation bar -->
<div class="container-fluid" style="margin-top: -10px;">
<nav class="navbar navbar-light navbar-expand-sm">
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
<div class="navbar-nav">
<a class="nav-item nav-link" href="/link-1">link</a>
<a class="nav-item nav-link" href="/link-2">link</a>
<a class="nav-item nav-link" href="/link-3">link</a>
</div>
</div>
</nav>
</div>
The result looks like the following:
Good luck!
<div class="fixed-top">
<div class="collapse" id="navbarToggleExternalContent">
<div class="bg-dark p-4">
<h5 class="text-white h4">Collapsed content</h5>
<span class="text-muted">Toggleable via the navbar brand.</span>
</div>
</div>
<nav class="navbar navbar-dark bg-dark">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-
target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent" aria-
expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</nav>
</div>
Hi so i got this from boostrap 4.5 navbar. My issue is that when i click on the menu picture it drops to the bottom left corner upon collapse. I want it to stay on the top left corner how do i do that? thanks
place the id=navbarToggleExternalContent after the button navbar-toggler - like in the snippet below:
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<div class="fixed-top">
<nav class="navbar navbar-dark navbar-expand-lg bg-dark">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarToggleExternalContent" aria-controls="navbarToggleExternalContent" aria- expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<!-- Navbar content -->
<div class="collapse navbar-collapse" id="navbarToggleExternalContent">
<ul class="navbar-nav">
<div class="bg-dark p-4">
<h5 class="text-white h4">Collapsed content</h5>
<span class="text-muted">Toggleable via the navbar brand.</span>
</div>
</ul>
</div>
</nav>
</div>
The button that is used on mobile devices to view the navbar is not showing up when I make the browser window size smaller to see how it looks on mobile. Here is a CodePen to see my code
<div class="container">
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<a class="navbar-brand" href="#"><h4>EmulateOS.tk</h4></a>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>Mac OS9</li>
<li>DOS</li>
<li>Windows '95</li>
</ul>
<form class="navbar-form navbar-left" role="search">
<input type="text" class="form-control" placeholder="Search">
<button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"></span></button>
</form>
</div>
</div>
</div>
</div>
The nav is supposed to disappear on mobile screens - in mobile views, the menu is visible by activating the menu by clicking a button. The navbar-collapse class ensures this. See the Bootstrap docs for how to achieve this:
http://getbootstrap.com/components/#navbar
And their examples for different ways this can be implemented:
http://getbootstrap.com/getting-started/#examples
Specifically, this is the critical aspect for your code:
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<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="#">Brand</a>
</div>
Your code is missing few boot strap styles. Here is the working code -
http://codepen.io/anon/pen/BzAWVa
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bootstrap Course</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<style type="text/css">
body {
padding: 60px;
}
</style>
</head>
<body>
<!-- Fixed navbar -->
<nav class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<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="#">EmulateOS.tk</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>Mac OS9</li>
<li>DOS</li>
<li>Windows '95</li>
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"></span></button>
</form>
</div>
</div><!--/.nav-collapse -->
</nav>
<div class="container">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Panel title</h3>
</div>
<div class="panel-body">
Panel content
</div>
</div>
<a data-target="#myModal" role="button" class="btn btn-warning" data-toggle="modal"><span class="glyphicon glyphicon-hand-up"></span>Sign up for weekly newsletter</a>
<div class="modal fade" id="myModal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Sign up for the newsletter</h4>
<div class=modal-body>
</div>
</div>
</div>
</div>
</div>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</body>
</html>