Bootstrap nav wouldn't close - html

I know that there are other posts with the same subject, but I tried a lot of them but still got the problem.
I can perfectly open the nav, but when I want to close it, it just flicker, and it doesn't close at all.
<nav class="navbar navbar-default">
#*navbar navbar-default*#
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#menu-collapse" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<p class="hidden-sm hidden-md hidden-lg">#Model.Content.Name</p>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="menu-collapse">
<ul class="nav navbar-nav">
#foreach (var item in selection)
{
if (item.Children.Count() > 0)
{
<li class="dropdown #(item.Id == Model.Content.Id ? "current" : null)">
#item.Name.ToUpper()
<ul class="dropdown-menu">
#foreach (var child in item.Children)
{
<li class="#(item.Id == Model.Content.Id ? "current" : null)">
#child.Name.ToUpper()
</li>
}
</ul>
</li>
}
else
{
<li class="#(item.Id == Model.Content.Id ? "current" : null)">
#item.Name.ToUpper()
</li>
}
}
</ul>
</div><!-- /.navbar-collapse -->
Html.RequiresCss("/css/bootstrap.min.css", 1);
Html.RequiresCss("/css/bootstrap-responsive.css", 1);
Html.RequiresJs("https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js", 0);
Html.RequiresJs("/Scripts/bootstrap.min.js", 1);
I hope that someone know what can cause this error.

Related

Responsive nav bar menu not working on mobile browser (handlebars # ResearchSpace)

I'm running this ResearchSpace (RS) instance: https://www.magnetic-margins.com
In the header.hbs file, all seems to be set for a use of the navbar on mobile devices, but the dropdown won't work because the collapse event is not triggered, I think. I can make it permanently collapsed for mobiles but I fail to make the actual dropdown work!
RS is using React Bootstrap 3. The corresponding lines in the header.hbs file are:
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="rs-header">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#rs-navbar"
aria-expanded="false" aria-controls="rs-navbar" aria-label="Toggle navigation">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="rs-header-logo" href="/" title="{{deploymentTitle}}"><img class="img-responsive" src="https://docs.google.com/drawings/d/e/2PACX-1vRKgdbvCgd7aA4xA3nCR21qrQpFvD6ryeqhLHJ2z15oDVb8lBMVLyPgOwRAiJxpUMVPK7HUvcogCVW9/pub?h=70"/></a>
</div>
​
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="rs-navbar">
​
<ul class="nav navbar-nav">
{{!-- <li>
<semantic-link iri="http://www.researchspace.org/resource/ThinkingFrames"
urlqueryparam-view='system-projects' class="rs-body-m-B" style="padding-left: 60px;">
Projects
</semantic-link>
</li> --}}
</ul>
​
<ul class="nav navbar-nav icon-btns-container">
​
​ <li>
<semantic-link uri="http://www.researchspace.org/resource/magnet_Persons">
<div class="nav-iconAndLabel">
<i class="fa fa-users"></i>
<div>Persons</div>
</div>
</semantic-link>
</li>
...
This bug seems to apply to all RS instances I checked, but, e.g., works on a Metaphacts implementation of http://db.sphaera.mpiwg-berlin.mpg.de/resource/Start

Bootstrap toggable menu icon doesn't work on small device

i added at my hoe page a navbar with toggable icon on small screen; It is the typical navbar of bootstrap.
I have the problem that when i go on developer tool and resize the screen in order to test the responsive part, happen that the icon doesn't toggle, it is like is not active.
Any help?
Here is the code:
<nav id="header" class="navbar navbar-default">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navmenu" aria-expanded="false" aria-controls="navmenu">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><img id="logo" src="images/art-of-hair.png"></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div id="navmenu" class="collapse navbar-collapse navbar-right">
<ul class="nav navbar-nav">
<li class="active">Home<span class="sr-only">Home</span></li>
<li>Hair Styles</li>
<li class="">About</li>
<li class="">Contact</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
and css:
* {
margin: 0;
}
body {
font-family: 'Alice', serif;
}
#header {
height:200px;
}
#logo {
width: 300px;
height:150px;
}
#navmenu {
margin:30px 120px 0 0;
}
In case of toggle, I guess you also need some jQuery to make the toggle function.
Maybe try something like this:
<script>
$("button").click(function(){
$("#navmenu").slideToggle();
});
</script>

Bootstrap Navbar Dropdown style when collapsed/not

Beginner project - I'm working on something with Bootstrap and have mostly finished building my Navbar. When the Navbar goes into collapsed mode I like the dropdown menu a lot and I want to have it this way at all times.
I cant for the life of me figure out what is even making it change to begin with
The left one is how it looks when it is collapsed, and how I wish to have it at all times (notice how it automatically centers the dropdown here as well):
http://imgur.com/a/yFVaE
I found that if I tweaked the CSS so that the page is always in collapsed mode, the dropdown still has the 2 styles and changes where collapsed mode used to kick in
Apologies - beginner here, new to StackOver flow as well, hope this makes sense to someone :) cheers
<nav class="navbar-fixed-top navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand cornerlogo" href="/">
<img class="logo" alt="Brand" src="/img/Logo1.png">
</a>
<!--<p class="navbar-brand centerme">Current Client Name</p>-->
<ul class="nav navbar-nav navbar-default centerme">
<li class="dropdown">
Current Client Name <span class="caret"></span>
<ul class="dropdown-menu dropdown-menu-right scrollable-menu">
<li class="newclient">New Client</li>
<li role="separator" class="divider"></li>
<li>client1</li>
<li>client2</li>
<li>client3</li>
</ul>
</li>
</ul>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<!--******************php if statement here to check if client selected-->
<form class="navbar-form navbar-right">
<button type="submit" class="btn btn-default">New SABR</button>
<button type="submit" class="btn btn-default">Edit Client</button>
<!--</form>-->
<!--<form class="navbar-form navbar-right">-->
</form>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
I dont know how to properly show my css, but not sure its relevant as even if i disable ALL CSS on the page the behavior is the same

href not working not moving page to linked file

i used href to link file used this
`
when user clicks on logo user will be redirected to link but in my case its not working.
Also tried:
can someone help what's wrong in this you can also live demo here http://www.xpoter.in/blog/ just click on logo you can find error
my head tag
<div class="navbar-wrapper">
<div class="container">
<div class="navbar navbar-default navbar-fixed-top" role="navigation" id="top-nav">
<div class="container">
<div class="navbar-header">
<!-- Logo Starts -->
<!-- #Logo Ends -->
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Nav Starts -->
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right scroll">
<li class="active">Home</li>
<li >About</li>
<li >Partners</li>
<li >Contact</li>
</ul>
</div>
<!-- #Nav Ends -->
</div>
</div>
</div>
</div>
The problem is a piece of jQuery on your page:
jQuery(document).ready(function ($) {
$(".scroll a, .navbar-brand, .gototop").click(function (event) {
event.preventDefault();
$('html,body').animate({scrollTop: $(this.hash).offset().top}, 600, 'swing');
$(".scroll li").removeClass('active');
$(this).parents('li').toggleClass('active');
});
});
Which fires on click of .navbar-brand, and you are using event.preventDefault() which is preventing your link from working

Navbar collapsed is closing while clicking on dropdown-toggle

When the navbar is collapsed, I can't click on the elements on the dropdowns because when I click on a dropdown, it's closing the navbar. How can I avoid this behavior ?
<nav ng-app="app" ng-controller="AppCtrl" class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle" ng-init="navCollapsed = true" ng-click="navCollapsed = !navCollapsed">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse" collapse="navCollapsed" ng-click="navCollapsed=true">
<ul class="nav navbar-nav pull-right">
<li id="home-tab" ng-class="{active : isActive('home-tab')}" ng-click="activateTab('home-tab')" class="tab"><span class="glyphicon glyphicon-home"></span>Home</li>
<li id="stats-tab" ng-class="{active : isActive('stats-tab')}" ng-click="activateTab('stats-tab')" class="tab"><span class="glyphicon glyphicon-stats"></span>Stats</li>
<li id="administration-tab" ng-class="{active : isActive('administration-tab')}" ng-click="activateTab('administration-tab')" class="tab dropdown"><a class="dropdown-toggle"><span class="glyphicon glyphicon-book"></span>Administration<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Content</li>
<li>Terminal</li>
<li>Users</li>
</ul>
</li>
<li id="profile-tab" ng-class="{active : isActive('profile-tab')}" ng-click="activateTab('profile-tab')" class="tab dropdown"><a data-toggle="dropdown" class="dropdown-toggle"><span class="glyphicon glyphicon-user"></span>Profile<span class="caret"></a>
<ul class="dropdown-menu">
<li>Me</li>
<li>Company</li>
</ul>
</li>
<li id="logout-tab" class="tab"><a><span class="glyphicon glyphicon-off"></span>Logout</a></li>
</ul>
</div>
</div>
</nav>
JSFiddle
Note: In the JSFiddle example, when you click on a dropdown, it is not expending. I don't know why, anyway it is working in my code. Forget that and look at the issue that makes my collapsed navbar closing while clickng on a dropdown. ;)
It's because you have
ng-click="navCollapsed=true"
on the main navbar div
<div class="collapse navbar-collapse" collapse="navCollapsed" ng-click="navCollapsed=true">
which means that the navbar closes anywhere you click on it, not just on the tabs.
Here is a version that doesn't collapse the navbar when you click on 'Administration' - Fiddle
<div class="collapse navbar-collapse" collapse="navCollapsed">
New activateTab:
$scope.activateTab = function(tabId) {
if (tabId != 'administration-tab') {
$scope.navCollapsed = true;
}
$scope.activeTab = tabId;
};