Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make scrolling collapsing navigation navbar-fixed-top?

How to make scrolling collapsing navigation navbar-fixed-top bootstrap4?

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
	<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.2.0/js/tether.min.js"></script>
	<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.3/css/bootstrap.min.css">
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.3/js/bootstrap.min.js"></script>
</head>
<body>
	<div class="container-fluid">
		<nav class="navbar navbar-fixed-top navbar-light bg-faded">
			<div class="container">
				<a class="navbar-brand" href="#">Fixed top</a>
				<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#exCollapsingNavbar" aria-controls="exCollapsingNavbar" aria-expanded="false" aria-label="Toggle navigation">
			    &#9776;
			  </button>
			  <div class="collapse" id="exCollapsingNavbar">
			    <div class="p-a-1">
			      <ul class="nav navbar-nav nav-pills nav-stacked">
					  <li class="nav-item">
					    <a class="nav-link active" href="#">Active</a>
					  </li>
					  <li class="nav-item">
					    <a class="nav-link" href="#">Link</a>
					  </li>
					  <li class="nav-item">
					    <a class="nav-link" href="#">Link</a>
					  </li>
					  <li class="nav-item">
					    <a class="nav-link disabled" href="#">Disabled</a>
					  </li>
					  <li class="nav-item">
					    <a class="nav-link disabled" href="#">Disabled</a>
					  </li>
					  <li class="nav-item">
					    <a class="nav-link disabled" href="#">Disabled</a>
					  </li>
					  <li class="nav-item">
					    <a class="nav-link disabled" href="#">Disabled</a>
					  </li>
					  <li class="nav-item">
					    <a class="nav-link disabled" href="#">Disabled</a>
					  </li>
					  <li class="nav-item">
					    <a class="nav-link disabled" href="#">Disabled</a>
					  </li>
					  <li class="nav-item">
					    <a class="nav-link disabled" href="#">Disabled</a>
					  </li>
					  <li class="nav-item">
					    <a class="nav-link disabled" href="#">Disabled</a>
					  </li>
					  <li class="nav-item">
					    <a class="nav-link disabled" href="#">Disabled</a>
					  </li>
					  <li class="nav-item">
					    <a class="nav-link disabled" href="#">Disabled</a>
					  </li>
					  <li class="nav-item">
					    <a class="nav-link disabled" href="#">Disabled</a>
					  </li>
					  <li class="nav-item">
					    <a class="nav-link disabled" href="#">Disabled</a>
					  </li>
					  <li class="nav-item">
					    <a class="nav-link disabled" href="#">Disabled</a>
					  </li>
					  <li class="nav-item">
					    <a class="nav-link disabled" href="#">Disabled</a>
					  </li>
					  <li class="nav-item">
					    <a class="nav-link disabled" href="#">Disabled</a>
					  </li>
					</ul>
			    </div>
			  </div>
			</div>
		</nav>
	</div>
</body>
</html>
like image 594
user220409 Avatar asked Sep 10 '16 21:09

user220409


1 Answers

In 4 alpha you to add some CSS to make the navbar stack vertically when collapse like 3.x..

.navbar .navbar-nav>.nav-item {
    float: none;
    margin-left: .1rem;
}
.navbar .navbar-nav {
    float:none !important;
    max-height: 240px;
    overflow: auto;
}
.navbar .collapse.in, .navbar .collapsing  {
    clear:both;
}

Demo: http://www.codeply.com/go/zeSsTQr8S9

like image 59
Zim Avatar answered Nov 04 '22 03:11

Zim