Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap 3 mobile menu 100% height

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

like image 988
niksos Avatar asked Oct 30 '14 18:10

niksos


5 Answers

You could try using the vh CSS unit:

.navbar-collapse {
    height: 100vh;
}
like image 97
cvrebert Avatar answered Nov 06 '22 20:11

cvrebert


.navbar-collapse.collapse {
    transition: height 0.2s;
}
.navbar-collapse.collapsing {
    height: 0 !important;
}
.navbar-collapse.collapse.in {
    max-height: none;
    height: 100vh;
}
like image 23
jteks Avatar answered Nov 06 '22 22:11

jteks


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;
}
like image 6
JKL Avatar answered Nov 06 '22 21:11

JKL


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

like image 2
Zim Avatar answered Nov 06 '22 21:11

Zim


This will do the trick!

.navbar-collapse { 
    max-height: 100% !important; 
}
like image 1
UXTY Avatar answered Nov 06 '22 22:11

UXTY