twitter bootstrap - moving objects to navbar when collapsed bootstrap 3 - html

I got a topnavbar which disappears when the website gets loaded on a mobile device but I would like the content that is on that topnavbar to appear on the collapsed main navigation.
TOPNAVBAR
COLLAPSED NAVIGATION
How would I be able to achieve this or is this even possible or do I have to create a class specially for the collapsed menu?
Thank you in advance

What I sometimes do is the following:
1) You create your top-menu container for big devices
2) You create the same menu in your collapse container for small devices
3) Use css and #media to switch between to 2 lists
<header>
<div class="container">
<!-- Top menu for not mobile devices -->
<div id="top-menu" class="clearfix">
<ul class="nav navbar-nav">
<li>
<a href="#">
TopItem1
</a>
</li>
<li>
<a href="#">
TopItem2
</a>
</li>
</ul>
</div>
<!-- Navigation bar -->
<div class="navbar navbar-default">
<div class="navbar-header">
<!-- Toggle menu -->
<button class="navbar-toggle" data-target=".navbar-collapse" data-toggle="collapse" type="button">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- Logo -->
<a class="navbar-brand" href="/nl/">
</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#">
Item1
</a>
</li>
<li>
<a href="#">
Item2
</a>
</li>
<li>
<a href="#">
Item2
</a>
</li>
</ul>
<!-- Same top menu links for small devices -->
<ul class="nav navbar-nav navbar-right" id="top-responsive">
<li>
<a href="#">
TopItem1
</a>
</li>
<li>
<a href="#">
TopItem2
</a>
</li>
</ul>
</div>
</div>
</div>
</header>
CSS:
Standard css style:
#top-responsive {
display: none;
}
#top-menu {
display: block;
}
With #media for small devices:
#media (max-width: 767px)
{
#top-responsive {
display: block;
}
#top-menu {
display: none;
}
}
Jsfiddle: http://jsfiddle.net/VDesign/qyosv002/
EDIT:
Like Vicente said, Bootstrap provides utility classes that does the same thing I do.
You can find the intell about it on the website of Bootstrap: http://getbootstrap.com/css/#responsive-utilities

Related

Uneven Bootstrap Pills when Collapsed

The following code produces "pills" of unequal width when displayed on small or extra small screens (as defined by twitter bootstrap by default).
<header>
<div id="brand" class="container">
<div class="row">
<div class="col-sm-12">
<h1>Website</h1>
<h2>header</h2>
</div>
</div>
</div>
<div id="navbar" class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navs">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="navs" class="collapse navbar-collapse">
<ul class="nav nav-pills nav-justified">
<li class="active">
Home
</li>
<li>
About
</li>
<li>
Portfolio
</li>
<li>
Blog
</li>
<li>
Contact
</li>
</ul>
</div>
</div>
</header>
The first pill seems to be exactly 2 pixels wider than the rest. I would prefer that the pills fill the entire width of the display.
Is this a bug in Bootstrap, or something I can remedy via some simple CSS?
JSFiddle: https://jsfiddle.net/elikmiller/z2og3vq7/
why don't you override bootstrap css with your custom css just add your custom class for example nav-custom and put this css into your custom css file
.nav-custom>li>a {
padding: 10px 10px;
}
fiddle
You should use another class in your html called nav-stacked. I updated your Fiddle you can see here the full example and can see here the relevant HTML part.
<ul class="nav nav-pills nav-stacked nav-justified">
<li class="active">
This one is 2px wider
</li>
<li>
About
</li>
<li>
Portfolio
</li>
<li>
Blog
</li>
<li>
Contact
</li>
</ul>

Bootstrap collapsed navbar showing empty

When I click on the hamburger menu in my nicely collapsed bootstrap navbar on my phone, the layout slides to the side as expected, but shows me an empty white (or whatever body background colour I have) bar instead of the navigation. Closer inspection with firebug showed that upon clicking the button, some classes got changed on the navbar-collapsebut it remains tagged as invisible.
I have recompiled Bootstrap from LESS to change the point at which it collapses, but the issue seems persistent even with 'vanilla' bootstrap.
Code:
<nav class="navbar transparent navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header" style="padding-right: 0px; min-width: 50px;">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navigation-example-2">
<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 hidden-xs hidden-sm" href="index.html"><span class="glyphicon glyphicon-home" style="padding-right: 0px;"></span></a><a class="navbar-brand hidden-lg hidden-md" href="index.html">De Fijnkost</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="navigation-example-2">
<ul class="nav navbar-nav navbar-right">
<li>
Fijne Vleeswaren
</li>
<li>
Bereide Gerechten
</li>
<li>
Eigen salades
</li>
<li>
Kazen & Kaasschotels
</li>
<li>
Belegde Broodjes
</li>
<li>
Contact
</li>
<li>
Nieuws
</li>
<li class="dropdown">
<a class="dropdown-toggle btn btn-white btn-fill" data-toggle="dropdown" href="#">Bestel <span class="caret"></span></a>
<ul class="dropdown-menu">
<li>
Kaasschotel
</li>
<li class="disabled">
Broodjes
</li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid-->
</nav>
Same thing happens on pages without the transparent or navbar-fixed-top class. transparent is added by my CSS. Page is visible on defijnkost.be
Your .navbar-collapse is set to display: none !important as far as I can see.
If you set it to display: block in your mobile view media query it should show up just fine.

How to display text only in the collapsable navbar

Navbar how it should be:
I want the text idealize, develop, prototype and about to appear next to the icons only in the collapsable navbar. The text appears on larger viewport sizes, too, what I don't want:
HTML
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" id="logo" href="#">
<img src="images/avezlogo.png">
</a>
</div>
<div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li id="orange"><a href="#idealize">
<img src="images/bulb.png"><span class="collapse">idealize</span>
</a></li>
<li id="cyan"><a href="#develop">
<img src="images/laptop.png"><span class="tittle">develop</span>
</a></li>
<li id="purple"><a href="#prototype">
<img src="images/printer.png"><span class="tittle">prototype</span>
</a></li>
<li id="red" class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#about">
<img src="images/dots.png" id="dots"><span class="tittle">about</span>
</a>
</li>
</ul>
</div>
</div>
</nav>
Sorry about any noob mistakes on my code. I'm new to Bootstrap and web design. Any help is appreciated. Thanks!
You can use display: none; inside of a media query to target and hide your images at the mobile breakpoint. See example.
#media (min-width: 768px) {
.navbar-inverse .navbar-nav li img {
display: none;
}
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> <span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" id="logo" href="#">
<img src="images/avezlogo.png">
</a>
</div>
<div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav navbar-right">
<li id="orange">
<a href="#idealize">
<img src="images/bulb.png"><span class="collapse"> idealize</span>
</a>
</li>
<li id="cyan">
<a href="#develop">
<img src="images/laptop.png"><span class="tittle"> develop</span>
</a>
</li>
<li id="purple">
<a href="#prototype">
<img src="images/printer.png"><span class="tittle"> prototype</span>
</a>
</li>
<li id="red" class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#about">
<img src="images/dots.png" id="dots"><span class="tittle"> about</span>
</a>
</li>
</ul>
</div>
</div>
</div>
</nav>
That's how it should behave. Links should be seen in all viewport sizes. If you only want to see the links in the collapsable navbar and not in the not-collapsable navbar, you can do this:
#media (min-width: 768px) {
#myNavbar .navbar-right {
display: none;
}
But then you see in larger viewport sizes a blank navbar without a toggle icon on the right side. And that's not what you want, I think.
If you want a collapsable navbar all the time, the best solution would be to customize the Bootstrap CSS here:
Bootstrap customize grid
and set the #grid-float-breakpoint to a large width, e.g. 3000px. Download and compile and the CSS should do it.
the media query worked fine. Thanks a lot. I was also wondering. Why doesn't the dropdown menu in the first image close after clicking one of the links? I have to click the menu button again for it to close. How could I change this? Thanks again.

Bootstrap 3 Navbar Mobile Issue

I am having trouble getting bootstrap 3's navabar to be responsive on a mobile device. The navbar continues to span further than the mobile display, and I cannot figure out what I did wrong.
The Code:
(HTML)
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navigationbar">
<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 img-responsive" href="index.html">
<img src="img/logo.png" width="320" height="85" alt="">
</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="navigationbar">
<ul class="nav navbar-nav navbar-right">
<li>
Home
</li>
<li>
Getting Started
</li>
<li class="dropdown">
Products <b class="caret"></b>
<ul class="dropdown-menu">
<li>
Brain Seedâ„¢
</li>
</ul>
</li>
<li>
About Us
</li>
<li>
FAQ
</li>
<li>
Contact Us
</li>
<li>
<button type="button pull-right" class="btn btn-success">ORDER NOW</button>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
The Code: (CSS)
.navbar-fixed-top .nav {
padding: 20px 0;
}
.navbar-fixed-top .navbar-brand {
padding: 0 15px;
}
.page-content {
padding-top: 40px;
}
.img-center {
display: block;
margin: 0 auto;
}
.navbar .brand {
max-height: 40px;
max-width: 30%;
overflow: visible;
padding-top: 0;
padding-bottom: 0;
}
I notice you in your html code, you typed fixed height and width, which cancels the img-responsive class.
Start by removing that and go from there...enter link description here

Display text while hover on menu

I've been working on my website using twitter bootstrap, and there's one thing that I'm probably not doing right.
I want to have some text to appear in the menu while I mouse hover on one of the links. Here's what I have:
HTML:
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<!-- Responsive Navbar Part 1: Button for triggering responsive navbar (not covered in tutorial). Include responsive CSS to utilize. -->
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<!-- Responsive Navbar Part 2: Place all navbar contents you want collapsed withing .navbar-collapse.collapse. -->
<div class="nav-collapse collapse">
<ul class="nav">
<li>Back</li>
<li><a href="prev_page.html" class=""previous >Previous</a></li>
<li><a href="next_page.html" class="next" >Next</a></li>
<li><span class="shownext">View next</span></li>
</ul>
</div><!--/.nav-collapse -->
</div><!-- /.navbar-inner -->
</div><!-- /.navbar navbar-inverse-->
CSS:
.nav .shownext {
font-weight: normal;
font-style: italic;
font-size: 11px;
display: none;
}
.next:hover + .nav .shownext {
display: block;
}
Any help will be appreciated.
You can use tooltips to be fancy or just the title attribute:
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<!-- Responsive Navbar Part 1: Button for triggering responsive navbar (not covered in tutorial). Include responsive CSS to utilize. -->
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<!-- Responsive Navbar Part 2: Place all navbar contents you want collapsed withing .navbar-collapse.collapse. -->
<div class="nav-collapse collapse">
<ul class="nav">
<li>Back</li>
<li><a href="prev_page.html" data-toggle="tooltip" data-placement="bottom" title="second tooltip" class=""previous >Previous</a></li>
<li><a href="next_page.html" data-toggle="tooltip" data-placement="top" title="third tooltip" class="next" >Next</a></li>
<li><span class="shownext" data-toggle="tooltip" data-placement="top" title="view next">View next</span></li>
</ul>
</div><!--/.nav-collapse -->
</div><!-- /.navbar-inner -->
</div><!-- /.navbar navbar-inverse-->
<script>$('li a').tooltip(options)</script>
Result
This is kinda what You asked. But since Your question wasn't to specific I don't think it's really what You wanted.
http://jsfiddle.net/xM6u9/1/
<div class="navbar">
<div class="navbar-inner"> <a class="brand" href="#">Title</a>
<ul class="nav">
<li class="active">Home
</li>
<li>Link
</li>
<li>Link
</li>
<li class="shownext">Next
</li>
</ul>
</div>
</div>
css:
.shownext { display: none; }
li:hover + .shownext { display: block; }
"Next" is showing up when You hover on last item.