Materialize dropdown in nav is behind elements - html

I know this type of questions has been asked, I went over them but could not solve my problem.
In my page where I am using materialize, I have a nav bar with a dropdown button but whenever i open it, it would be behind another element. I am attaching a image of it
I am attaching a image of it.
I have made a similar problem in fiddle,
https://jsfiddle.net/Illuminator0/pugy1j5b/10/
<ul id='dropdown1' class='dropdown-content'>
<li><a class='dropdown-button d' href='#' data-activates='dropdown2' data-hover="hover" data-alignment="left">Drop Me!</a></li>
<li>two</li>
<li class="divider"></li>
<li>three</li>
</ul>
<ul id='dropdown2' class='dropdown-content'>
<li>one</li>
<li>two</li>
<li class="divider"></li>
<li>three</li>
</ul>
<nav>
<div id="nav-wrapper">
<ul class=" brand-logo center">
<li>
<a class='dropdown-button btn' href='#' data-activates='dropdown1' data-beloworigin="true">Drop Me!</a>
</li>
</ul>
</div>
</nav>
<div class="row">
<div class="col s12 m6">
<div class="card blue-grey darken-1">
<div class="card-content white-text">
<span class="card-title">Card Title</span>
<p>I am a very simple card. I am good at containing small bits of information.
I am convenient because I require little markup to use effectively.</p>
</div>
<div class="card-action">
This is a link
This is a link
</div>
</div>
</div>
</div>
I would appreciate the help.

I used the above solution to solve the problem, here's a fiddle of it
CSS code
.dropdown-content {
overflow-y: auto;
position: relative;
z-index: 1000;
}
.dropdown-content .dropdown-content {
margin-left: 100%;
position: relative;
z-index: 1000;
}
.nav-wrapper {
overflow-y: auto;
position: relative;
}
.card {
overflow: visible;
position: relative;
}
nav {
position: relative;
z-index: 9999;
}

here is the solution i just add "z-index-1" in .card class
.dropdown-content {
overflow-y: auto;
position: relative;
z-index: 1000;
}
.dropdown-content .dropdown-content {
margin-left: 100%;
position: relative;
z-index: 1000;
}
.nav-wrapper {
overflow-y: auto;
position: relative;
}
.card {
overflow: visible;
position: relative;
z-index:-1;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.1/css/materialize.min.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.1/js/materialize.min.js"></script>
<ul id='dropdown1' class='dropdown-content'>
<li><a class='dropdown-button d' href='#' data-activates='dropdown2' data-hover="hover" data-alignment="left">Drop Me!</a></li>
<li>two</li>
<li class="divider"></li>
<li>three</li>
</ul>
<ul id='dropdown2' class='dropdown-content'>
<li>one</li>
<li>two</li>
<li class="divider"></li>
<li>three</li>
</ul>
<nav>
<div id="nav-wrapper">
<ul class=" brand-logo center">
<li>
<a class='dropdown-button btn' href='#' data-activates='dropdown1' data-beloworigin="true">Drop Me!</a>
</li>
</ul>
</div>
</nav>
<div class="row">
<div class="col s12 m6">
<div class="card blue-grey darken-1">
<div class="card-content white-text">
<span class="card-title">Card Title</span>
<p>I am a very simple card. I am good at containing small bits of information.
I am convenient because I require little markup to use effectively.</p>
</div>
<div class="card-action">
This is a link
This is a link
</div>
</div>
</div>
</div>

Looks like the major problem is that the div with an id of nav-wrapper should be a class. Your css looks for that class but there is none so never gets applied. Then in that class get rid of the overflow: auto and add z-index: 1000.
Here is the fiddle.
And a snippet...
.dropdown-content {
overflow-y: auto;
position: relative;
z-index: 1000;
}
.dropdown-content .dropdown-content {
margin-left: 100%;
position: relative;
z-index: 1000;
}
.nav-wrapper {
/*overflow-y: auto;*/
position: relative;
z-index: 1000;
}
.card {
overflow: visible;
position: relative;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.1/css/materialize.min.css">
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.97.1/js/materialize.min.js"></script>
<ul id='dropdown1' class='dropdown-content'>
<li><a class='dropdown-button d' href='#' data-activates='dropdown2' data-hover="hover" data-alignment="left">Drop Me!</a></li>
<li>two</li>
<li class="divider"></li>
<li>three</li>
</ul>
<ul id='dropdown2' class='dropdown-content'>
<li>one</li>
<li>two</li>
<li class="divider"></li>
<li>three</li>
</ul>
<nav>
<div class="nav-wrapper">
<ul class=" brand-logo center">
<li>
<a class='dropdown-button btn' href='#' data-activates='dropdown1' data-beloworigin="true">Drop Me!</a>
</li>
</ul>
</div>
</nav>
<div class="row">
<div class="col s12 m6">
<div class="card blue-grey darken-1">
<div class="card-content white-text">
<span class="card-title">Card Title</span>
<p>I am a very simple card. I am good at containing small bits of information. I am convenient because I require little markup to use effectively.</p>
</div>
<div class="card-action">
This is a link
This is a link
</div>
</div>
</div>
</div>

Related

How do I make the background of a flex UL stretch for a dynamic number of columns?

I am trying to style a main navigation component, but I'm having trouble getting the background to stretch for a dynamic number of wrapped columns in the submenu popup. Can anyone help with this jsfiddle? I have exhausted my admitidly limited knowledge of CSS as well as anything I could find through google.
The markup comes from a content management system, so I have limited control of the generated markup, other than adding additional CSS classes, although I have full control over the CSS.
I almost got it working properly using column-count, but the number of columns need to be dynamic. I found other posts mentioning using display: flex, but still can't quite get the combination of flex and inline-block working properly.
This is the layout I am trying to achieve:
.container {
display: flex;
position: relative;
}
.container a {
text-decoration: none;
color: #424242;
}
ul {
list-style: none;
}
.main-navitation>.component-content {
position: absolute;
bottom: 0;
right: 0;
}
.rel-level1 {
display: inline-block;
padding: 10px;
position: relative;
}
.rel-level1>ul {
display: flex;
position: absolute;
top: 30px;
left: 0;
background: #e1e1e1;
border: 1px solid #c2c2c2;
padding: 5px;
max-height: 200px;
flex-wrap: wrap;
flex-direction: column;
}
.rel-level1>ul>li {
display: block;
}
.rel-level2 {
display: inline-block;
flex-grow: 1;
flex-shrink: 1 auto;
flex-basis: 100%;
width: 85px;
}
.rel-level2>a>.navigation-title {
display: inline-block;
font-weight: bold;
}
.rel-level2>ul {
padding-left: 0;
}
.rel-level3 {
padding-top: 3px;
display: inline-block;
width: 85px;
}
.rel-level3>a>.navigation-title {
border-bottom: solid 1px transparent;
display: inline-block;
font-size: 14px;
}
<div class="container">
<div class="navigation main-navigation">
<div class="component-content">
<nav>
<ul>
<li class="rel-level1">
<div class="navigation-title">Level 1</div>
<ul>
<li class="rel-level2">
<a href="/" class="navigation-title">
<div class="navigation-title">Submenu 1</div>
</a>
<ul>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
</ul>
</li>
<li class="rel-level2">
<a href="/" class="navigation-title">
<div class="navigation-title">Submenu 2</div>
</a>
<ul>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
</ul>
</li>
<li class="rel-level2">
<a href="/" class="navigation-title">
<div class="navigation-title">Submenu 3</div>
</a>
<ul>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
</nav>
</div>
</div>
</div>
Thanks!
It's a combination of factors:
You have your flex-direction set to column, when you're wanting row (which is actually the default, so you can remove the property from your CSS entirely), have a look at https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction
You've set a max-height to try to force the child elements to flow horizontally, alongside using flex-wrap: wrap. Neither of these properties are required if you change your flex-direction.
FYI, you can further simplify your HTML code, and even if you don't know CSS well, remove those rules which reference the unnecessary HTML code that can be removed:
ul {
list-style: none;
}
.rel-level1 {
display: inline-block;
padding: 10px;
position: relative;
}
.rel-level1>ul {
display: flex;
position: absolute;
top: 30px;
left: 0;
background: #e1e1e1;
border: 1px solid #c2c2c2;
padding: 5px;
max-height: 200px;
flex-wrap: wrap;
flex-direction: column;
}
.rel-level1>ul>li {
display: block;
}
.rel-level2 {
display: inline-block;
flex-grow: 1;
flex-shrink: 1 auto;
flex-basis: 100%;
width: 85px;
}
.rel-level2>a>.navigation-title {
display: inline-block;
font-weight: bold;
}
.rel-level2>ul {
padding-left: 0;
}
.rel-level3 {
padding-top: 3px;
display: inline-block;
width: 85px;
}
.rel-level3>a>.navigation-title {
border-bottom: solid 1px transparent;
display: inline-block;
font-size: 14px;
}
<ul>
<li class="rel-level1">
<ul>
<li class="rel-level2">
<a href="/" class="navigation-title">
<div class="navigation-title">Submenu 1</div>
</a>
<ul>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
</ul>
</li>
<li class="rel-level2">
<a href="/" class="navigation-title">
<div class="navigation-title">Submenu 2</div>
</a>
<ul>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
</ul>
</li>
<li class="rel-level2">
<a href="/" class="navigation-title">
<div class="navigation-title">Submenu 3</div>
</a>
<ul>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
<li class="rel-level3">
<a href="/" class="navigation-title">
<div class="navigation-title">Level 3</div>
</a>
</li>
</ul>
</li>
</ul>
</li>
</ul>
That said, your question is a duplicate of this post.

How to store the | in HTML?

I was wondering what will be the best practice for me to use the | i.e. do I wrap it in a div class or store it in a span tag? Basically what I want to achieve is the following.
Ask a question | Privacy | Statement
<!DOCTYPE html>
<html>
<body>
<footer role="contentinfo">
<div class="footer-bottom hidden-print">
<div class="Container">
<div class="row">
<div class="col-12">
<ul class="list list--inline" role="menu" aria-label="Navigation">
<li role="menuitem" aria-label="Ask a question">
Ask a question |
</li>
<li role="menuitem" aria-label="Privacy">
Privacy |
</li>
<li role="menuitem" aria-label="Statement">
Statement
</li>
</ul>
</div>
</div>
</div>
</div>
</footer></body>
</html>
Please advise.
No need to have special characters at all.
Just use a right-border...
ul {
display:flex;
justify-content:center;
list-style:none;
}
li {
padding:0 1em;
}
li:not(:last-child) {
border-right:3px solid red;
}
<footer role="contentinfo">
<div class="footer-bottom hidden-print">
<div class="Container">
<div class="row">
<div class="col-12">
<ul class="list list--inline" role="menu" aria-label="Navigation">
<li role="menuitem" aria-label="Ask a question">
Ask a question
</li>
<li role="menuitem" aria-label="Privacy">
Privacy
</li>
<li role="menuitem" aria-label="Statement">
Statement
</li>
</ul>
</div>
</div>
</div>
</div>
</footer>
Alternatively, use a pseudo-element
ul {
display: flex;
justify-content: center;
list-style: none;
}
li {
padding: 0 1em;
position: relative;
}
li:not(:last-child):after {
content: "";
position: absolute;
right: 0;
top: 10%;
height: 80%;
width: 3px;
background: green;
}
<footer role="contentinfo">
<div class="footer-bottom hidden-print">
<div class="Container">
<div class="row">
<div class="col-12">
<ul class="list list--inline" role="menu" aria-label="Navigation">
<li role="menuitem" aria-label="Ask a question">
Ask a question
</li>
<li role="menuitem" aria-label="Privacy">
Privacy
</li>
<li role="menuitem" aria-label="Statement">
Statement
</li>
</ul>
</div>
</div>
</div>
</div>
</footer>
You can use CSS border-right with pseudo-selectors for this so you don't have to have the pipe (|) in your markup.
Pseudo-Selectors
:not() -- exclude what is inside the brackets
:first-child -- first of this type of descendant
:last-child -- last of this type of descendant
descendant, as in your markup, as li is the child (descendant) of ul.
ul[role="menu"].list {
list-style: none;
display: flex;
}
li[role="menuitem"]:not(:first-child) {
padding-left: 0.5rem;
}
li[role="menuitem"]:not(:last-child) {
padding-right: 0.5rem;
border-right: 1px solid grey;
}
<footer role="contentinfo">
<div class="footer-bottom hidden-print">
<div class="Container">
<div class="row">
<div class="col-12">
<ul class="list list--inline" role="menu" aria-label="Navigation">
<li role="menuitem" aria-label="Ask a question">
Ask a question
</li>
<li role="menuitem" aria-label="Privacy">
Privacy
</li>
<li role="menuitem" aria-label="Statement">
Statement
</li>
</ul>
</div>
</div>
</div>
</div>
</footer>

show full page overlay while sub navigation is opened using css

I wanted to show the overlay while sub menu is opened using css, I have tried below thing, it's doing the trick but I am not able to get back to nav links since the overlay is on top.
.header .navbar .nav .nav-item div.big-menu {
position: absolute;
display: block;
opacity: 0;
width: 100%;
max-height: 450px;
top: 80px;
left: 0;
z-index: 399;
visibility: hidden;
overflow: hidden;
background: #ffffff;
color: #181717;
-webkit-transition: all 0.3s ease 0.15s;
transition: all 0.3s ease 0.15s;
}
.header .navbar .nav .nav-item div.big-menu .big-menu-body {
position: relative;
overflow: hidden;
background-color: white
}
.header .navbar .nav .nav-item:hover > div {
opacity: 1;
visibility: visible;
overflow: visible;
}
/* Used :after to apply overlay */
.header .navbar .nav .nav-item:hover > div:before {
content: '';
position: fixed;
z-index: auto;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: rgba(0, 0, 0, 0.6);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css" rel="stylesheet"/>
<script src="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/js/bootstrap.js" integrity="sha384-XXXXXXXX" crossorigin="anonymous"></script>
<body>
<div class="header">
<div class="container">
<nav class="navbar navbar-light bg-faded">
<a class="navbar-brand" href="#">Navbar</a>
<ul class="nav navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Sub Menu</a>
<div class="big-menu">
<div class="big-menu-body bg-img-2">
<div class="row big-menu-container">
<div class="col-md-8">
<div class="skew-text">
<div class="big-menu-nav two-col">
<div class="row">
<div class="col-md-6">
<h5>Categories</h5>
<ul class="sm-nav-item">
<li>Category Item</li>
<li>Category Item</li>
<li>Category Item</li>
<li>Category Item</li>
<li>Category Item</li>
<li>Category Item</li>
<li>Category Item</li>
</ul>
</div>
<div class="col-md-6">
<h5>Our work</h5>
</div>
</div>
<blockquote>
More than a big idea. Lorem ipsum dolor sit amet, consectetur adipiscing elit
</blockquote>
<a href="" class="btn read-more read-more-primary">
Our Clients
</a>
</div>
</div>
</div>
<div class="col-md-4 menu-info">
<div class="info-text top-padding text-center">
<h5>FEATURED</h5>
<h3>Bla Bla</h3>
View details
</div>
</div>
</div>
<!--end big menu grid-->
</div>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
</ul>
</nav>
<!--end nav-->
</div>
<!--end container-->
</div>
<!--end header-->
</body>
As you can see, its over the nav, I wanted to keep the navigation active to show other links.
Please help
Is that what you want?
Just changed top:0px to top:55px of .header .navbar .nav .nav-item:hover > div:before
$(document).ready(function(){
$(".nav-link.sub").mouseover(function(){
$(".header").css("background", "rgba(0,0,0,0.6)");
});
$(".nav-link.sub").mouseout(function(){
$(".header").css("background", "#fff");
});
});
.header{
transition:0.6s;
}
.header .navbar .nav .nav-item div.big-menu {
position: absolute;
display: block;
opacity: 0;
width: 100%;
max-height: 450px;
top: 80px;
left: 0;
z-index: 399;
visibility: hidden;
overflow: hidden;
background: #ffffff;
color: #181717;
-webkit-transition: all 0.3s ease 0.15s;
transition: all 0.3s ease 0.15s;
}
.header .navbar .nav .nav-item div.big-menu .big-menu-body {
position: relative;
overflow: hidden;
background-color: white
}
.header .navbar .nav .nav-item:hover > div {
opacity: 1;
visibility: visible;
overflow: visible;
}
/* Used :after to apply overlay */
.header .navbar .nav .nav-item:hover > div:before {
content: '';
position: fixed;
z-index: auto;
width: 100%;
height: 100%;
top: 54px;
left: 0;
background-color: rgba(0, 0, 0, 0.6);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/css/bootstrap.css" rel="stylesheet"/>
<script src="https://cdn.rawgit.com/twbs/bootstrap/v4-dev/dist/js/bootstrap.js" integrity="sha384-XXXXXXXX" crossorigin="anonymous"></script>
<body>
<div class="header">
<div class="container">
<nav class="navbar navbar-light bg-faded">
<a class="navbar-brand" href="#">Navbar</a>
<ul class="nav navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link sub" href="#">Sub Menu</a>
<div class="big-menu">
<div class="big-menu-body bg-img-2">
<div class="row big-menu-container">
<div class="col-md-8">
<div class="skew-text">
<div class="big-menu-nav two-col">
<div class="row">
<div class="col-md-6">
<h5>Categories</h5>
<ul class="sm-nav-item">
<li>Category Item</li>
<li>Category Item</li>
<li>Category Item</li>
<li>Category Item</li>
<li>Category Item</li>
<li>Category Item</li>
<li>Category Item</li>
</ul>
</div>
<div class="col-md-6">
<h5>Our work</h5>
</div>
</div>
<blockquote>
More than a big idea. Lorem ipsum dolor sit amet, consectetur adipiscing elit
</blockquote>
<a href="" class="btn read-more read-more-primary">
Our Clients
</a>
</div>
</div>
</div>
<div class="col-md-4 menu-info">
<div class="info-text top-padding text-center">
<h5>FEATURED</h5>
<h3>Bla Bla</h3>
View details
</div>
</div>
</div>
<!--end big menu grid-->
</div>
</div>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
</ul>
</nav>
<!--end nav-->
</div>
<!--end container-->
</div>
<!--end header-->
</body>

Make content opaque when nav menu is open

I want to make a translucent mask appear over the content when I open the navbar.
Here is my code:
<nav class="navbar navbar-default">
<div class="collapse navbar-collapse"">
<ul class="nav navbar-nav">
<li>Home</li>
<li class="dropdown">
About
<ul class="dropdown-menu">
<li>What</li>
<li>How</li>
</ul>
</li>
</ul>
</div>
</nav>
<div class= "content">
<div class = "container">
<div class = "row">
<div class="col-sm-10">
Enter Text Here
</div>
</div>
</div>
Is there a way to do this using just css?
Something like sibling selector if class is added to active nav item?
nav.active + .content {
display: block;
width: 100%;
height: 100%;
content: " ";
position: absolute;
background: rgba(0,0,0,0.6);
left: 0;
top: 0;
z-index: 999;
}

Bootstrap 3 Vertical Nav bar

I want to create navigation bar [vertical] with bootstrap 3.
I tried this but it didn't work.
<ul class="nav nav-pils nav-stacked">
<li>jedan</li>
<li>dva</li>
<li>tri</li>
<li>cetriri</li>
<li>pet</li>
</ul>
I tried a lot of examples but it is all with old bootstrap. How to create that navigation with new bootstrap?
nav-pills class needs two l:
<ul class="nav nav-pills nav-stacked">
<li>jedan</li>
<li>dva</li>
<li>tri</li>
<li>cetriri</li>
<li>pet</li>
</ul>
http://getbootstrap.com/components/#nav-pills
It looks like you are missing an l in nav-pills (you have it listed as nav-pils)
<ul class="nav nav-pills nav-stacked">
<li>jedan</li>
<li>dva</li>
<li>tri</li>
<li>cetriri</li>
<li>pet</li>
</ul>
http://getbootstrap.com/components/#nav-pills
you could use the pills or you just could write this:
your html:
<!--navigation-->
<div class="navbar navbar-inverse navbar-fixed-left">
<a class="navbar-brand" href="#">LOGO</a>
<ul class="nav navbar-nav">
<li><i class="fa fa-home"></i><span> Link1 </span></li>
<li><i class="fa fa-info-circle"></i><span> Link2 </span></li>
<li><i class="fa fa-heart"></i><span> Link3 </span></li>
<li><i class="fa fa-briefcase"></i><span> Link4 </span></li>
<li><i class="fa fa-envelope"></i><span> Link5 </span></li>
</ul>
</div>
<!--end navigation-->
<!-- 1st section-->
<div class="wrapper">
<div class="container" id="home">
<div class="row">
<h2>Link 1</h2>
</div>
</div>
<!-- 2nd section-->
<div class="container" id="info">
<div class="row">
<h2>Link 2</h2>
</div>
</div>
<!--3rd section-->
<div class="container" id="love">
<div class="row">
<h2>Link 3</h2>
</div>
</div>
<!--4th section-->
<div class="container" id="work">
<div class="row">
<h2>Link 4</h2>
</div>
</div>
<!--5th section-->
<div class="container" id="contact">
<div class="row">
<h2>Link 5</h2>
</div>
</div>
</div>
your css:
/* CSS used here will be applied after bootstrap.css */
.navbar-fixed-left {
width: 140px;
position: fixed;
border-radius: 0;
height: 100%;
}
.navbar-fixed-left .navbar-nav > li {
float: none; /* Cancel default li float: left */
width: 139px;
}
.navbar-fixed-left + .container {
padding-left: 160px;
}
.container {
height: 1000px;
}
.wrapper {
margin-left: 140px;
}
working example here: bootply
I came late to the party but in case you just got here and you would like to add toggle to your vertical nav:
<nav class="list-group">
<ul class="nav">
<li>
<a href="#" id="btn-1" data-toggle="collapse" data-target="#submenu1" aria-expanded="false" class="list-group-item">Item 1
</a>
<ul class="nav collapse" id="submenu1" role="menu" aria-labelledby="btn-1">
<li>
<a href="#" class="list-group-item">
Item 2
</a>
</li>
<li>
<a href="#" class="list-group-item">
Item 3
</a>
</li>
</ul>
</li>
</ul>
</nav>
Use navbar-pills. It will work.