Answer the question
In order to leave comments, you need to log in
Why does the menu immediately collapse?
Made a hamburger menu that opens at all resolutions. But there was a problem, the menu, when pressed, opens and immediately closes.
Working example (more precisely, not working)
.navbar-toggle {
z-index: 999;
display: block;
width: 32px;
height: 32px;
margin-right: 15px;
background: transparent;
border: none;
}
.navbar-toggle:hover,
.navbar-toggle:focus,
.navbar-toggle:active {
outline: none;
}
.navbar-toggle.is-closed,
.navbar-toggle.is-open {
-webkit-transition: all 0.5s ease;
-moz-transition: all 0.5s ease;
-o-transition: all 0.5s ease;
transition: all 0.5s ease;
}
.navbar-toggle.is-closed:before {
content: '';
display: block;
width: 100px;
font-size: 14px;
color: #fff;
line-height: 32px;
text-align: center;
opacity: 0;
-webkit-transform: translate3d(0,0,0);
-webkit-transition: all 0.35s ease-in-out;
}
.navbar-toggle.is-closed:hover:before {
opacity: 1;
display: block;
-webkit-transform: translate3d(-100px,0,0);
-webkit-transition: all 0.35s ease-in-out;
}
.navbar-toggle.is-open:before {
content: '';
display: block;
width: 100px;
font-size: 14px;
color: #fff;
line-height: 32px;
text-align: center;
opacity: 0;
-webkit-transform: translate3d(0,0,0);
-webkit-transition: all 0.35s ease-in-out;
}
.navbar-toggle.is-open:hover:before {
opacity: 1;
display: block;
-webkit-transform: translate3d(-100px,0,0);
-webkit-transition: all 0.35s ease-in-out;
}
/******/
.navbar-header {
float: none;
}
.navbar-toggle {
display: block;
}
.navbar-collapse {
border-top: 1px solid transparent;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.1);
}
.navbar-collapse.collapse {
display: none!important;
}
.navbar-nav {
float: none!important;
margin: 7.5px -15px;
}
.navbar-nav>li {
float: none;
}
.navbar-nav>li>a {
padding-top: 10px;
padding-bottom: 10px;
}
$(document).ready(function () {
var trigger = $('.navbar-toggle'),
isClosed = false;
trigger.click(function () {
navtoggle_cross();
});
function navtoggle_cross() {
if (isClosed == true) {
trigger.removeClass('is-open');
trigger.addClass('is-closed');
isClosed = false;
} else {
trigger.removeClass('is-closed');
trigger.addClass('is-open');
isClosed = true;
}
}
});
Answer the question
In order to leave comments, you need to log in
Add to styles
.navbar-collapse.collapse.in {
display: block!important;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question