Getting Bootstrap 3 Tab Panes to Work with TreeView - twitter-bootstrap-3

I am trying to get the TreeView from BootSnipp here: 1 to work with Bootstrap 3 tabs.
It works as expected initially, but breaks down after a few clicks, then responding/not responding arbitrarily. Here's the html+js+css I am working with:
// ***************** BEGIN TREE JS *****************
$.fn.extend({
treed: function() {
return this.each(function() {
//initialize each of the top levels
var tree = $(this);
tree.addClass("tree");
tree.find('li').has("ul").each(function() {
var branch = $(this); //li with children ul
branch.prepend("<i class='indicator glyphicon glyphicon-plus-sign'></i>");
branch.addClass('branch');
branch.on('click', function(e) {
if (this == e.target) {
var icon = $(this).children('i:first');
icon.toggleClass("glyphicon-minus-sign glyphicon-plus-sign");
$(this).children().children().toggle();
}
})
branch.children().children().toggle();
});
//fire event from the dynamically added icon
$('.branch .indicator').on('click', function() {
$(this).closest('li').click();
});
//fire event to open branch if the li contains an anchor instead of text
$('.branch a').on('click', function(e) {
$(this).closest('li').click();
e.preventDefault();
});
//fire event to open branch if the li contains a button instead of text
$('.branch button').on('click', function(e) {
$(this).closest('li').click();
e.preventDefault();
});
});
}
});
$('.tree').treed();
//***************** END TREE JS *****************
/*BEGIN TREE CSS*/
.tree,
.tree ul {
margin: 0;
padding: 0;
list-style: none
}
.tree ul {
margin-left: 1em;
position: relative
}
.tree ul ul {
margin-left: .5em
}
.tree ul:before {
content: "";
display: block;
width: 0;
position: absolute;
top: 0;
bottom: 0;
left: 0;
border-left: 1px solid
}
.tree li {
margin: 0;
padding: 0 1em;
line-height: 2em;
color: #369;
font-weight: 700;
position: relative
}
.tree ul li:before {
content: "";
display: block;
width: 10px;
height: 0;
border-top: 1px solid;
margin-top: -1px;
position: absolute;
top: 1em;
left: 0
}
.tree ul li:last-child:before {
background: #fff;
height: auto;
top: 1em;
bottom: 0
}
.indicator {
margin-right: 5px;
}
.tree li a {
text-decoration: none;
color: #369;
}
.tree li button,
.tree li button:active,
.tree li button:focus {
text-decoration: none;
color: #369;
border: none;
background: transparent;
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
outline: 0;
}
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<div class="container">
<div class="row">
<div class="col-xs-7">
<ul id="tabs" class="tree">
<li>Continent Overview
</li>
<li>Countries
<ul>
<li>Country 1
<ul>
<li>Country Overview
</li>
</ul>
</li>
<li>Country 2
<ul>
<li>Country Overview
</li>
<li>Cities
<ul>
<li>City P
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>Cities
<ul>
<li>
City A
<ul>
<li>Overview
</li>
</ul>
</li>
<li>
City B
<ul>
<li>Overview
<li>Neighborhoods
<ul>
<li>Neighborhood X
</li>
</ul>
</li>
</li>
</ul>
</li>
</ul>
</li>
<li>Neighborhoods
<ul>
<li>Neighborhood T
</li>
</ul>
</li>
</ul>
</div>
<div class="col-xs-5">
<div class="tabbable" id="tabbable-proj">
<div class="tab-content main-tab-content">
<div class="tab-pane fade in active" id="panel-continent-overview">
<strong>Continent Details</strong>
</div>
<div class="tab-pane fade" id="panel-country-9400470e-fa49-46ea-b587-2ceb108600c0">
<strong>Country Details</strong>
</div>
<div class="tab-pane fade" id="panel-country-45f97844-9773-4059-bafd-a2782fc06db1">
<strong>Country Details</strong>
</div>
<div class="tab-pane fade" id="panel-city-2120d7aa-2b93-4d0d-a42b-8c6fedc9333a">
<strong>City Details</strong>
</div>
<div class="tab-pane fade" id="panel-neighborhood-babea547-cfb6-4e12-8c4a-bbbb25068d8a">
<strong>Neighborhood Details</strong>
</div>
<div class="tab-pane fade" id="panel-city-b4a991ce-80ef-4406-b1d2-9892c0d93d18">
<strong>City Details</strong>
</div>
<div class="tab-pane fade" id="panel-city-2e6f1227-66d0-4061-9243-bf6cf4feaabd">
<strong>City Details</strong>
</div>
<div class="tab-pane fade" id="panel-neighborhood-f3fd5e2f-583d-4ccb-b163-03e118896f71">
<strong>Neighborhood Details</strong>
</div>
<div class="tab-pane fade" id="panel-neighborhood-319d56ac-286f-4afa-af42-5ec74bbcac19">
<strong>Neighborhood Details</strong>
</div>
</div>
</div>
</div>
</div>
</div>
I am totally at a loss as to what is causing the problem. Could someone please help me with flushing out the bug?

Okay, I will attempt it myself.
It was not working because Bootstrap expects the tabs to be one flat ul - and I had multiple nested uls.
I got it working by
dissociating the tree from the tabbable;
creating a hidden flat ul for tabs; and
hooking the relevant tree anchor clicks to manually call $('...).tab('show') on the respective tab.
I have also discovered that using this strategy, I can call up my tabs from anywhere on the page - e.g. from a breadcrumb or a random anchor.
Now I know my question was too noobish for most people out there to tackle - the html itself was all over the place.
The answer I have been able to work out looks slightly hackish. Will somebody at least comment as to how good or bad it is? Like, will it incur search engine penalties for hiding the ul? What will the implications for accessibility be - especially as I have removed text from the anchor tags?
Or should I post one or more new questions to solicit this kind of feedback?
Cheers
// ***************** BEGIN TREE JS *****************
$.fn.extend({
treed: function() {
return this.each(function() {
//initialize each of the top levels
var tree = $(this);
tree.addClass("tree");
tree.find('li').has("ul").each(function() {
var branch = $(this); //li with children ul
branch.prepend("<i class='indicator glyphicon glyphicon-plus-sign'></i>");
branch.addClass('branch');
branch.on('click', function(e) {
if (this == e.target) {
var icon = $(this).children('i:first');
icon.toggleClass("glyphicon-minus-sign glyphicon-plus-sign");
$(this).children().children().toggle();
}
})
branch.children().children().toggle();
});
//fire event from the dynamically added icon
$('.branch .indicator').on('click', function() {
$(this).closest('li').click();
});
//fire event to open branch if the li contains an anchor instead of text
$('.branch a').on('click', function(e) {
$(this).closest('li').click();
e.preventDefault();
});
//fire event to open branch if the li contains a button instead of text
$('.branch button').on('click', function(e) {
$(this).closest('li').click();
e.preventDefault();
});
});
}
});
$('.tree').treed();
//***************** END TREE JS *****************
$(document).ready(function() {
$("a.tree-link").on('click', function (event) {
var hrefTab = $(this).attr('href');
$('#hidden-tabs a[href='+hrefTab+']').tab('show');
});
});
#hidden-tabs{
height: 0px;
list-style-type: none;
padding:0;
margin:0;
}
#hidden-tabs{
height: 0px;
list-style-type: none;
padding:0;
margin:0;
}
#hidden-tabs li{
height: 0px;
padding:0;
margin:0;
}
#hidden-tabs li a{
height: 0px;
padding:0;
margin:0;
}
/*BEGIN TREE CSS*/
.tree,
.tree ul {
margin: 0;
padding: 0;
list-style: none
}
.tree ul {
margin-left: 1em;
position: relative
}
.tree ul ul {
margin-left: .5em
}
.tree ul:before {
content: "";
display: block;
width: 0;
position: absolute;
top: 0;
bottom: 0;
left: 0;
border-left: 1px solid
}
.tree li {
margin: 0;
padding: 0 1em;
line-height: 2em;
color: #369;
font-weight: 700;
position: relative
}
.tree ul li:before {
content: "";
display: block;
width: 10px;
height: 0;
border-top: 1px solid;
margin-top: -1px;
position: absolute;
top: 1em;
left: 0
}
.tree ul li:last-child:before {
background: #fff;
height: auto;
top: 1em;
bottom: 0
}
.indicator {
margin-right: 5px;
}
.tree li a {
text-decoration: none;
color: #369;
}
.tree li button,
.tree li button:active,
.tree li button:focus {
text-decoration: none;
color: #369;
border: none;
background: transparent;
margin: 0px 0px 0px 0px;
padding: 0px 0px 0px 0px;
outline: 0;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="row">
<div class="col-xs-7">
<ul class="tree">
<li>Continent Overview
</li>
<li>Countries
<ul>
<li>Country 1
<ul>
<li>Country Overview
</li>
</ul>
</li>
<li>Country 2
<ul>
<li>Country Overview
</li>
<li>Cities
<ul>
<li>City P
</li>
</ul>
</li>
</ul>
</li>
</ul>
</li>
<li>Cities
<ul>
<li>
City A
<ul>
<li>Overview
</li>
</ul>
</li>
<li>
City B
<ul>
<li>Overview
<li>Neighborhoods
<ul>
<li>Neighborhood X
</li>
</ul>
</li>
</li>
</ul>
</li>
</ul>
</li>
<li>Neighborhoods
<ul>
<li>Neighborhood T
</li>
</ul>
</li>
</ul>
</div>
<div class="col-xs-5">
<div class="tabbable" id="tabbable-proj">
<ul id="hidden-tabs" role="tablist" aria-expanded="false">
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
<li>
</li>
</ul>
<div class="tab-content main-tab-content">
<div class="tab-pane fade in active" id="panel-continent-overview">
<strong>Continent Details</strong>
</div>
<div class="tab-pane fade" id="panel-country-9400470e-fa49-46ea-b587-2ceb108600c0">
<strong>Country 1 Details</strong>
</div>
<div class="tab-pane fade" id="panel-country-45f97844-9773-4059-bafd-a2782fc06db1">
<strong>Country 2 Details</strong>
</div>
<div class="tab-pane fade" id="panel-city-2120d7aa-2b93-4d0d-a42b-8c6fedc9333a">
<strong>City P Details</strong>
</div>
<div class="tab-pane fade" id="panel-neighborhood-babea547-cfb6-4e12-8c4a-bbbb25068d8a">
<strong>Neighborhood Details</strong>
</div>
<div class="tab-pane fade" id="panel-city-b4a991ce-80ef-4406-b1d2-9892c0d93d18">
<strong>City A Details</strong>
</div>
<div class="tab-pane fade" id="panel-city-2e6f1227-66d0-4061-9243-bf6cf4feaabd">
<strong>City B Details</strong>
</div>
<div class="tab-pane fade" id="panel-neighborhood-f3fd5e2f-583d-4ccb-b163-03e118896f71">
<strong>Neighborhood X Details</strong>
</div>
<div class="tab-pane fade" id="panel-neighborhood-319d56ac-286f-4afa-af42-5ec74bbcac19">
<strong>Neighborhood T Details</strong>
</div>
</div>
</div>
</div>
</div>
</div>

Related

object-fit: cover and IE11

I'm using object-fit: cover; in my CSS to line up images on a page, because they need to be the same height. It works perfectly in most browsers however IE11 is distorting the images.
I read that I might be able to use #support to fix this but I don't understand how to do this? Or is there another option that I might be able to use?
The code I have used is below - would really appreciate any help.
.brands {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
grid-gap: 1rem;
}
.brands__item img {
display: block;
/* Make sure max-width is added */
max-width: 100%;
height: 70px;
}
.brands__item img {
width: 130px;
height: 75px;
object-fit: contain;
}
.brands__item a {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
}
<div class="row" style="padding: 10px 30px 40px;">
<hr style="border-color: #000000; border-width: 2px; width: 90px; margin-bottom: 10px;" />
<h5 style="text-align: center;font-size: 2.4rem;margin-bottom:30px;">Trending now</h5>
<ul class="brands">
<li class="brands__item">
<a href="#">
<img src="https://static.prd.echannel.linde.com/wcsstore/UK_BOC_Industrial_Ntl_Store/images/steel-blue-logo-148x75.png" alt="Steel Blue logo" />
</a>
</li>
<li class="brands__item">
<a href="#">
<img src="https://static.prd.echannel.linde.com/wcsstore/UK_BOC_Industrial_Ntl_Store/images/dewalt-logo-103x45.png" alt="Dewalt logo" />
</a>
</li>
<li class="brands__item">
<a href="#">
<img src="https://static.prd.echannel.linde.com/wcsstore/UK_BOC_Industrial_Ntl_Store/images/3m-logo-105x55.png" alt="3M logo" />
</a>
</li>
<li class="brands__item">
<a href="#">
<img src="https://static.prd.echannel.linde.com/wcsstore/UK_BOC_Industrial_Ntl_Store/images/bahco-logo-125x75.png" alt="Bahco logo" />
</a>
</li>
<li class="brands__item">
<a href="#">
<img src="https://static.prd.echannel.linde.com/wcsstore/UK_BOC_Industrial_Ntl_Store/images/honeywell-logo-211x40.png" alt="Honeywell logo" />
</a>
</li>
<li class="brands__item">
<a href="#">
<img src="https://static.prd.echannel.linde.com/wcsstore/UK_BOC_Industrial_Ntl_Store/images/metabo-logo-166x65.png" alt="Metabo logo" />
</a>
</li>
</ul>
</div>
<!-- end -->
I test your code in IE 11 and the issue seems not only with object-fit.
CSS Grid part of your code doesn't work in IE 11.
You need to use -ms- prefix to elements such as display: grid, grid-column and grid-row.
grid-template-areas isn't supported, you can convert it to work with grid lines.
The repeat() notation doesn't work in IE 11. You need to write in all row and column lengths.
object-fit is not supported by IE 11. You can refer to this thread for the fix.
I use #media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {} to target IE 11 in CSS to add some codes for IE 11 to fix the issue. The added code is like below:
#media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
.brands__item img {
width: 130px;
height: auto;
max-width: 100%;
max-height: 100%;
}
.brands {
display: -ms-grid;
-ms-grid-columns: 1fr 1fr 1fr 1fr 1fr 1fr;
}
li:nth-of-type(1) {
-ms-grid-column: 1;
-ms-grid-row: 1;
}
li:nth-of-type(2) {
-ms-grid-column: 2;
-ms-grid-row: 1;
}
li:nth-of-type(3) {
-ms-grid-column: 3;
-ms-grid-row: 1;
}
li:nth-of-type(4) {
-ms-grid-column: 4;
-ms-grid-row: 1;
}
li:nth-of-type(5) {
-ms-grid-column: 5;
-ms-grid-row: 1;
}
li:nth-of-type(6) {
-ms-grid-column: 6;
-ms-grid-row: 1;
}
}

search button to open search box in bootstrap navbar

I want to add search box to my navbar but not as the traditional way as appears in the picture , I want to add a search icon button in the navbar only and when user click on it the search box appears under the search icon .
How can i do this any one can help me please ?
<nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<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="#">Brand</a>
</div>
<div class="collapse navbar-collapse" >
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>Contact US</li>
<li class="dropdown">
Who we are <b class="caret"></b>
<ul class="dropdown-menu">
<li>About</li>
<li> Mession</li>
<li> Vision</li>
<li class="divider"></li>
<li>Goals</li>
</ul>
</li>
<li>Publications</li>
<li>Media</li>
<li>Partners</li>
</ul>
There are lot of things on the net e.g https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_anim_search
Run below code:
<!DOCTYPE html>
<html>
<head>
<style>
input[type=text] {
width: 130px;
box-sizing: border-box;
border: 2px solid #ccc;
border-radius: 4px;
font-size: 16px;
background-color: white;
background-image: url('https://www.w3schools.com/howto/searchicon.png');
background-position: 10px 10px;
background-repeat: no-repeat;
padding: 12px 20px 12px 40px;
-webkit-transition: width 0.4s ease-in-out;
transition: width 0.4s ease-in-out;
}
input[type=text]:focus {
width: 100%;
}
</style>
</head>
<body>
<p>Animated search form:</p>
<form>
<input type="text" name="search" placeholder="Search..">
</form>
</body>
</html>
You can try these snippets.
Solutuion with CSS Only:
.hide
{
opacity: 0;
max-height: 0;
}
#trigger {
position: absolute;
left: -999em;
}
#container input[type="checkbox"]:checked + div
{
max-height: 99em;
opacity: 1;
height: auto;
overflow: hidden;
}
<div id="container">
<label for="trigger">click me for Search</label>
<input type="checkbox" id="trigger">
<div class="hide">
<form>
<input type="text" name="search" placeholder="Search..">
</form>
</div>
<div>
Solution with JS:
function myFunction() {
if (document.getElementById("form").style.display === "none") {
document.getElementById("form").style.display = "block";
} else {
document.getElementById("form").style.display = "none";
}
}
button {
width: 50px;
height: 50px;
}
<p>show and hide search</p>
<button onclick="myFunction()"></button>
<form id="form">
<input type="text" name="search" placeholder="Search..">
</form>

Bootstrap Media Slider Carousel repeating items

I am using bootstrap media slider carousel. but, it is repeating items if items are less than 4. I want to slide one item per click.
see my code below
JQUERY
$(document).ready(function(){
$('#media').carousel({
pause: true,
interval: false
});
$('.carousel .item').each(function(){
var next = $(this).next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
for (var i=0;i<2;i++) {
next=next.next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
}
});
});
Already tried to change [for (var i=0;i<2;i++) {] i<4 and i<6 instead of i<2
CSS :
/* carousel */
.carousel-pack{height:40px; margin:0; padding:0;}
.carousel-pack-inner{width:252px; margin: 0 auto;}
.media-carousel
{
margin-bottom: 0;
margin-top: 20px;
}
.carousel-control{line-height: 24px;}
/* Previous button */
.media-carousel .carousel-control.left
{
left: -37px;
background-image: none;
background: none repeat scroll 0 0 #222222;
border: 2px solid #FFFFFF;
height: 32px;
width: 32px;
margin-top: 4px;
}
/* Next button */
.media-carousel .carousel-control.right
{
right: -37px;
background-image: none;
background: none repeat scroll 0 0 #222222;
border: 2px solid #FFFFFF;
height: 32px;
width: 32px;
margin-top: 4px;
}
/* Changes the position of the indicators */
.media-carousel .carousel-indicators
{
right: 50%;
top: auto;
bottom: 0px;
margin-right: -19px;
}
/* Changes the colour of the indicators */
.media-carousel .carousel-indicators li
{
background: #c0c0c0;
}
.media-carousel .carousel-indicators .active
{
background: #333333;
}
.thumbnail
{
width: 48px !important;
height: 40px!important;
border-radius:0;
border-radius: 8px !important;
}
.thumbs{
margin-right: 15px;
padding: 0;
float: left;
}
.thumbs:first-child{margin-left: 7px;}
.thumbs:last-child{margin-right: 7px;}
HTML
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div class="carousel-pack">
<div class="carousel-pack-inner">
<div class="carousel slide media-carousel" id="media">
<div class="carousel-inner">
<div class="item active">
<div class="row-new">
<div class="thumbs">
<a class="thumbnail" href="#">1</a>
</div>
</div>
</div>
<div class="item">
<div class="row-new">
<div class="thumbs">
<a class="thumbnail" href="#">2</a>
</div>
</div>
</div>
</div>
<a data-slide="prev" href="#media" class="left carousel-control">‹</a>
<a data-slide="next" href="#media" class="right carousel-control">›</a>
</div>
</div>
</div>
see it repeating 2. I have only two items 1 and 2. how can I stop repeating items?
Solved this by Splitting an array into chunks using array_chunk() and foreach.
HTML
<div class="carousel-pack">
<div class="carousel-pack-inner">
<div class="carousel slide media-carousel" data-ride="carousel" data-wrap="true" id="media">
<div class="carousel-inner">
<?php
$active = 'active';
$pages = array_chunk($file_array,3);
foreach ($pages as $key => $data) { ?>
<div class="item <?php echo $active; ?>">
<?php foreach ($data as $key => $value) { ?>
<div class="row-new">
<div class="thumbs">
<a class="thumbnail" href="#" target="_blank"><?php echo $value; ?></a>
</div>
</div>
<?php } ?>
</div>
<?php $active='';
} ?>
</div>
<a data-slide="prev" href="#media" class="left carousel-control">‹</a>
<a data-slide="next" href="#media" class="right carousel-control">›</a>
</div>
JQUERY
$(document).ready(function(){
$('#media').carousel({
pause: true,
interval: false
});
});

trying to use bootstrap 3 for nested columns but their being hidden

enter image description hereI'm trying to have an information panel with three different columns using bootstrap 3. I've nested the columns properly, I think, but the panels are hidden beneath the main row and I can't find a way to reveal it.
it's showing that the container is there, but you can't see it
<div class="row creative_line">
<div class="col-md-12">
<h2 class="text-center">Smart & Creative<br><p>This is why you will use it</p></h2>
</div>
<div class="col-md-12">
<div class="row">
<div class="col-md-4 multi">
<div class="img-circle">
</div>
</div>
<div class="col-md-4 ui">
<div class="img-circle">
</div>
</div>
<div class="col-md-4 design">
<div class="img-circle">
</div>
</div>
</div>
</div>
</div>
This is my current css
.creative_line {
background: yellow;
min-height: 300px;
color: $primary-color;
font-family: $font-stack;
}
.creative_line p {
color: $primary-color;
font-family: $font-stack2;
font-size: 35%;
margin-top: 10px;
}
h2 {
font-size: 40px;
}
.img-circle {
-webkit-clip-path: circle(50% at 50% 50%);
clip-path: circle(50% at 50% 50%);
background: red;
}
.multi,
.ui,
.design {
min-height: 300px;
color: blue;
z-index: 1;
}

How can I have a navigation menu with two rows, one fixed and one collapsable?

I'm trying to set a navigation menu at the top of the screen with two rows:
The former one will contain the Brand, and when the resolution is small enough it will also contain the special bootstrap button menu that displays the collapsed menu items stacked.
The second will contain the categories and will be visible only if the resolution is large enough.
This is what I want to achieve:
When the resolution is big enough
When the resolution is small, the second menu row is collapsed
I have used this code without success (The second row never appears):
<html>
<head>
<link rel="stylesheet" href="css/bootstrap.min.css">
</head>
<body>
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<a class="navbar-brand" href="#">Brand</a>
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="container">
<div class="nav-collapse collapse">
<ul class="nav navbar-nav">
<li>Cat1</li>
<li>Cat2</li>
<li>Cat3</li>
</ul>
</div>
</div>
</div>
<div class="container">
<p>some text</p>
</div>
</body>
</html>
Any idea?
I have updated your html code..and after changing a little bit of bootstrap styles you may get what you want..
<div class="navbar navbar-inverse navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" 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>
<a class="navbar-brand" href="#">Project name</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li>Cat1</li>
<li>Cat2</li>
<li>Cat3</li>
</ul>
</div>
</div>
</div>
Now set
.navbar-header {
float: none;
}
Now you will get all links below brand name
In bootstrap we can use media queries to set when to display toggle button in navigation menu.Here we can see toggle button when browser size is 500 px or lesser than 500 px(by default toggle button appears when browser size is lesser than 767 px)..
#media (min-width: 500px) {
.navbar-collapse {
width: auto;
border-top: 0;
box-shadow: none;
}
.navbar-collapse.collapse {
display: block !important;
height: auto !important;
padding-bottom: 0;
overflow: visible !important;
}
.navbar-collapse.in {
overflow-y: visible;
}
.navbar-fixed-top .navbar-collapse,
.navbar-static-top .navbar-collapse,
.navbar-fixed-bottom .navbar-collapse {
padding-right: 0;
padding-left: 0;
}
navbar-collapse.collapse {
display: block!important;
}
.navbar-toggle {
display: none;
}
.navbar-nav > li {
float: left;
}
}
#media (max-width: 500px) {
.navbar-toggle {
display: block;
}
.navbar-header {
float: none;
}
.navbar-toggle {
display: block!important;
}
.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;
}
}
Hope this helps you!!!!!