Bootstrap navbar does not include a cross icon by default. You can add the cross icon in your HTML code next to the navbar-toggler-icon
Here's an example:
<span class="navbar-toggler-icon"></span>
<span class="navbar-close-icon">X</span>
Apply some styles to it:
.navbar-toggler-icon {
display: none;
}
.navbar-close-icon {
display: inline-block;
width: 30px;
height: 30px;
line-height: 30px;
}
.navbar-toggler.collapsed .navbar-close-icon {
display: none;
}
.navbar-toggler.collapsed .navbar-toggler-icon {
display: inline-block;
}
Remember to add the collapsed
class to the
<button class="navbar-toggler navbar-toggler-right">
by default
Here's a complete example:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<link
rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous"
/>
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.7.0/css/all.css"
integrity="sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ"
crossorigin="anonymous"
/>
<style>
.navbar-toggler-icon {
display: none;
}
.navbar-close-icon {
display:inline-block;
width: 30px;
height: 30px;
line-height: 30px;
}
.navbar-toggler.collapsed .navbar-close-icon {
display: none;
}
.navbar-toggler.collapsed .navbar-toggler-icon {
display: inline-block;
}
</style>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button
class="navbar-toggler collapsed"
type="button"
data-toggle="collapse"
data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
<span class="navbar-close-icon">X</span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
</li>
<li class="nav-item active">
<a class="nav-link" href="#"
>Office <span class="sr-only">(current)</span></a
>
</li>
<li class="nav-item active">
<a class="nav-link" href="#"
>Windows<span class="sr-only">(current)</span></a
>
</li>
<li class="nav-item active">
<a class="nav-link" href="#"
>Xbox<span class="sr-only">(current)</span></a
>
</li>
<li class="nav-item active">
<a class="nav-link" href="#"
>Support<span class="sr-only">(current)</span></a
>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
</ul>
<ul class="navbar-nav mr-auto">
<li class="nav-item dropdown">
<a
class="nav-link dropdown-toggle"
href="#"
id="navbarDropdown"
role="button"
data-toggle="dropdown"
aria-haspopup="true"
aria-expanded="false"
>All Microsoft</a
>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li>
<a href="#" class="user"><i class="fas fa-search"></i></a>
</li>
<li>
<a href="#" class="user"><i class="fas fa-shopping-cart"></i></a>
</li>
<li>
<a href="#" class="user"><i class="far fa-user-circle"></i></a>
</li>
</ul>
</div>
</nav>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</body>
</html>