Content is hidden by navigation bar. How to fix? - html

I've a problem with a website I am working at.
The site has a navigation bar which looks quite good on a bigger desktop screen.
But if I resize the screen it looks ugly and content is hidden behind the navigation bar.
How to fix this? Code is the following for the header:
<nav class="navbar navbar-default navbar-fixed-top" id="navbar-fixed" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
</button>
<a class="navbar-brand" href="index.html">Dummy</a>
</div>
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>Werke</li>
<li>Kontakt</li>
<li>Dropdown <b class="caret"></b>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li class="divider"></li>
<li>Separated link</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Impressum</li>
</ul>
</div>
</nav>

Think I've found your issue. You need to wrap the menu in another <div> with the id which you have specified in your data-target attribute on the toggle button. And also give it the classes collapse navbar-collapse. So you will have the following for your menu section:
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>Werke</li>
<li>Kontakt</li>
<li>Dropdown <b class="caret"></b>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li class="divider"></li>
<li>Separated link</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>Impressum</li>
</ul>
</div>
I think just adding that div in should fix it. Here is a working jsfiddle: http://jsfiddle.net/Ca7B9/1/

Related

How to centre a navbar using css

I've been learning to use bootstrap so I decided to use it to create a Navbar. So, I decided to try and centre it so I looked online for a solution but none of them work. So please could you advise me on what to do.
HTML:
</head>
<body>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li class="dropdown">Items <span class="sr-only"></span>
<ul class="dropdown-menu">
<li>Item 1</li>
<li role="separator" class="divider"></li>
<li>Item 2 </li>
<li role="separator" class="divider"></li>
<li>Item 3</li>
</ul></li>
</ul>
</div>
Current CSS:
.navbar .navbar-nav {
display: inline-block;
float: none;
vertical-align: top;
}
.navbar .navbar-collapse {
text-align: center;
}
It looks like the CSS you have and code you have will work fine. Just wrap your div in a nav element.
<nav class="navbar navbar-default" role="navigation">
<div class="collapse navbar-collapse">
... Rest of Your Code ...
</div>
</nav>
try use this CSS code to solve your problem:
.navbar-collapse .navbar-nav{
margin: 0 auto;
width: 300px; /*(example - [width: auto; is wrong])*/
}
.navbar-collapse{
margin: 0 auto;
}
.navbar-collapse li{
margin: 0 auto;
}
If you are using bootstrap, why are you using your current CSS for navbar? Just use what bootstrap is offering.
I am not sure whether you mean to center the text in the navbar or center the navbar all together, but this is found on bootstrap's website
<body>
<div class="container">
<!-- Static navbar -->
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<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 id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li role="separator" class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li>Separated link</li>
<li>One more separated link</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="active">Default <span class="sr-only">(current)</span></li>
<li>Static top</li>
<li>Fixed top</li>
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container-fluid -->
</nav>

Way to choose a "default" navbar of a Bootstrap Material theme?

I'm using the Bootstrap Material Design Template for a website. It has three different colored navbars of which I want to use the last one. But I'm unsure how to use that last one. Do I need to manually change the color of the navbar, or can I change one thing somewhere so that the color of all the buttons and radio buttons also changes?
I found a piece on the github page which points out how to change the primary color to a cusom one. But I don't want that, I simply want to use the blue color which you see in the third navbar option here.
Any ideas how I can do that? All tips are welcome!
Actually you just have to use different classes for change in colors, by default a Bootstrap theme have navbar-default and navbar-inverse
But in the very theme you're using have a class called navbar-material-light-blue-300 which needs to be added in following manner.
<div class="navbar navbar-material-light-blue-300">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-material-light-blue-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="javascript:void(0)">Brand</a>
</div>
<div class="navbar-collapse collapse navbar-material-light-blue-collapse">
<ul class="nav navbar-nav">
<li class="active">Active</li>
<li>Link</li>
<li class="dropdown">
Dropdown <b class="caret"></b>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li class="dropdown-header">Dropdown header</li>
<li>Separated link</li>
<li>One more separated link</li>
</ul>
</li>
</ul>
<form class="navbar-form navbar-left">
<input type="text" class="form-control col-lg-8" placeholder="Search">
</form>
<ul class="nav navbar-nav navbar-right">
<li>Link</li>
<li class="dropdown">
Dropdown <b class="caret"></b>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
</ul>
</li>
</ul>
</div>
</div>
Happy Coding :)
.navbar-inverse is the class that affecting its color.
<div class="navbar navbar-inverse">
....
</div>
Other two above than the third have .navbar-default and .navbar-warning classes respectively.
Use below code:
<div class="navbar navbar-inverse">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-inverse-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="javascript:void(0)">Brand</a>
</div>
<div class="navbar-collapse collapse navbar-inverse-collapse">
<ul class="nav navbar-nav">
<li class="active">Active
</li>
<li>Link
</li>
<li class="dropdown">
Dropdown <b class="caret"></b>
<ul class="dropdown-menu">
<li>Action
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li class="divider"></li>
<li class="dropdown-header">Dropdown header</li>
<li>Separated link
</li>
<li>One more separated link
</li>
</ul>
</li>
</ul>
<form class="navbar-form navbar-left">
<input class="form-control col-lg-8" placeholder="Search" type="text">
</form>
<ul class="nav navbar-nav navbar-right">
<li>Link
</li>
<li class="dropdown">
Dropdown <b class="caret"></b>
<ul class="dropdown-menu">
<li>Action
</li>
<li>Another action
</li>
<li>Something else here
</li>
<li class="divider"></li>
<li>Separated link
</li>
</ul>
</li>
</ul>
</div>
</div>

How can I implement a collapsible/responsive sidebar nav in Bootstrap?

I'm using the flatly theme from bootswatch.com
It has a collapsible topnav bar, but I want to refactor it so it's a sidebar nav rather than topnav.
Here is the current code:
Toggle navigation
Brand
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active">Link <span class="sr-only">(current)</span></li>
<li>Link</li>
<li class="dropdown">
Dropdown <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
<li class="divider"></li>
<li>One more separated link</li>
</ul>
</li>
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<ul class="nav navbar-nav navbar-right">
<li>Link</li>
</ul>
</div>
</div>
I'm hoping I just have to change a few class names to get it to work before I invent my own method. (I'm new to bootstrap).

What does bootstrap mean when it says collapse?

I am learning bootstrap on Bootstrap's site
It say's about navbars:
Navbars are responsive meta components that serve as navigation
headers for your application or site. They begin collapsed (and are
toggleable) in mobile views and become horizontal as the available
viewport width increases.
Here is the
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<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>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active">Link</li>
<li>Link</li>
<li class="dropdown">
Dropdown <b class="caret"></b>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
<li class="divider"></li>
<li>One more separated link</li>
</ul>
</li>
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<ul class="nav navbar-nav navbar-right">
<li>Link</li>
<li class="dropdown">
Dropdown <b class="caret"></b>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
The problem is i can't understand what is collapse and why should one use them?
It means that the inline menu will become a drop down menu when the viewport size is not wide enough to display all the items.
Inline menu:
Collapsed menu:
Bootstrap shows that drop down menu with a button in the right-top corner. You'll have to click on it to see the available menu items.

bootstrap dropdown doesn't work

http://jsfiddle.net/Cwf4W/10/
there's my code I can't seem to get the bootstrap drop down menu to work, any help? I'm pretty sure I've got all the js right and the css too, I've been looking for awhile now :o
<!-- BOOTSTRAP -->
<div class="navbar navbar-inverse" style="position: static;">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".subnav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="#">Project Stalk</a>
<div class="nav-collapse subnav-collapse">
<ul class="nav">
<li class="active">Home</li>
<li>About</li>
<li>Contact</li>
<li class="dropdown">
Settings <b class="caret"></b>
<ul class="dropdown-menu">
<li>Account settings</li>
<li>Privacy settings</li>
<li>Logout</li>
<li class="divider"></li>
<li class="nav-header">Nav header</li>
<li>Separated link</li>
<li>One more separated link</li>
</ul>
</li>
</ul>
<form class="navbar-search pull-left" action="">
<input type="text" class="search-query span2" placeholder="Search">
</form>
<ul class="nav pull-right">
<li>Link</li>
<li class="divider-vertical"></li>
<li class="dropdown">
Dropdown <b class="caret"></b>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something else here</li>
<li class="divider"></li>
<li>Separated link</li>
</ul>
</li>
</ul>
</div><!-- /.nav-collapse -->
</div>
</div><!-- /navbar-inner -->
</div><!-- /navbar -->
Your code looks right, but several javascript files including http://www.sieuphan.com/bootstrap/bootstrap-dropdown.js return an error-404
The development console shows these errors clearly (e.g in Chrome "View > Developer > Javascript console")