Whats the best method for getting 100% height for collapse bootstrap menu (mobile).
.navbar-collapse { max-height: 100% !important; min-height: 100% !important; height: 100%;}
is not really working here
You could try using the vh
CSS unit:
.navbar-collapse {
height: 100vh;
}
.navbar-collapse.collapse {
transition: height 0.2s;
}
.navbar-collapse.collapsing {
height: 0 !important;
}
.navbar-collapse.collapse.in {
max-height: none;
height: 100vh;
}
None of the previous answers worked for me. My .navbar-collapse
has position: fixed;
but I assume this is also the case for the original question.
The key to solve this was to have the child element of .navbar-collapse
to have height: 100vh
.
Note: I'm using Bootstrap 4, so collapse.in
is now collapse.show
.
HTML code:
<div id="main-nav" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
...
</ul>
</div>
(S)CSS:
.navbar-collapse {
position: fixed;
top: 0;
left: 0;
width: 100%;
}
.navbar-collapse.collapse.show {
height: 100vh;
}
.navbar-nav {
height: 100vh;
}
I realize this is an older question, but none of the answers completely worked for me. The CSS that works is to set full height on the navbar-nav
:
.navbar-nav {
float: none!important;
margin-top: 7.5px;
height: 100vh;
}
https://www.bootply.com/EGHMYmOz2e
This will do the trick!
.navbar-collapse {
max-height: 100% !important;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With