I'm developing a web with Ruby on Rails, using Twitter-Bootstrap and Simple-Navigation gem. The navigation menu works fine on any browser, something like this:
When displaying the web on a mobile device and clicking the nav button, the whole menu is displayed on vertical block, enlarging the size of the header to a max. height than can hold the menu. The problem is that opening any submenú increases the size of the menu, overflowing and hiding the last options, as you can see in the comparison:
Any idea?
The code of nav_menu on the mobile version:
<div class="navbar navbar-static-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-target=".nav-collapse" data-toggle="collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<div class="brand">
<img alt="NRG Consulting logo" src="/assets/nrg-logo.png" title="NRG Consulting">
</div>
<span class="development" id="rails-env"><span>development</span></span>
<div class="container nav-collapse in collapse" style="height: 496px;">
<ul class="nav pull-right align-top">
<li>
<a href="manual_path">
Help
</a>
</li>
<li>
Español <img alt="Switch to English" class="lang" data-locale="en" src="/assets/lang-es.png" title="English">
</li>
</ul>
<ul class="nav pull-right align-bottom">
<li id="home">Home</li>
<li id="formulas">Formulas</li>
<li id="deals">Deals</li>
.
.
.
<li class="active dropdown" id="admin">
Admin <b class="caret"></b>
<ul class="dropdown-menu">
<li id="subscription">Subscriptions</li>
<li class="divider" id="nav_header"></li>
<li id="historic">Recalculate historic prices</li>
<li class="divider" id="nav_header"></li>
<li id="export">export data</li>
<li id="import_tuple_eod_check">Check data</li>
<li class="divider" id="nav_header"></li>
<li id="alerts">Alert</li>
<li id="product_price_alerts">Price alerts</li>
<li id="import_tuples">Import tuple</li>
<li id="fixing_errors">fixing errors</li>
<li class="divider" id="nav_header"></li><li id="redis">Resque</li>
<li id="copycopter">Translate</li>
<li class="divider" id="nav_header"></li>
<li class="active simple-navigation-active-leaf" id="client">Clients</li>
<li id="user">Users</li>
<li id="user_activities">User activity</li></ul></li>
<li id="user">Users</li>
</ul>
</div>
</div>
</div>
</div>
Collapsed nav menu appears to set a fixed height value when displaying nav menu, preventing the div to enlarging when submenu dropdowns display:
<div class="container nav-collapse in collapse" style="height: 496px;">
Adding this lines to style.css set height property to auto, allowing the div to enlarge when needed, showing the whole menu:
.container.nav-collapse.in.collapse{
height: auto !important;
}
Perhaps there is a cleaner solution, but this worked pretty fine for me, and don't want to change Bootstrap code itself.
A link displaying some usefull info about similar issues.
Related
I have a navbar that does collapse as it should in mobile view but on the tablet (or ipad pro) there is a break or large padding/gap that breaks the navigation. The testing site is at:
padding or margin bottom occurs in tablet view
I have tried a number of things like adjusting the viewport and adding links to bootstraps transition.js and collapse.js files but that is not working either.
<!--navigation bar-->
<nav class="navbar navbar-default transparent navbar-static-top" role="navigation" id="navbar-main">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="row">
<div class="col-lg-12"> <a class="navbar-brand" href="http://patskailua.com/index.php"><img src="http://patskailua.com/images/kailua-beach-properties-llc.png" alt="pats kailua hawaiian Flower" usemap="#Map" class="img-responsive">
</a></div>
</div>
</div>
</div>
</div>
<div class="navbar-header">
<div class="text-center">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navCollapse">
<span class="sr-only">Toggle Navigation</span>
<span class="fa fa-chevron-down"></span> Menu
</button>
<div class="collapse navbar-collapse" id="navCollapse">
<ul class="nav navbar-nav navbar-right">
<li class="active goleft1">vacation rentals</li>
<li>kailua activities</li>
<li class="dropdown">
rentals by size<span class="caret black"></span>
<ul class="dropdown-menu">
<li><a href="http://patskailua.com/wp/three-bedrooms.php" >Three Bedrooms</a></li>
<li>Two Bedrooms</li>
<li>One Bedrooms</li>
<li>Studios</li>
</ul>
</li><li>contact us </li>
<li>about us</li>
<li class="dropdown">
property management and sales<span class="caret black"></span>
<ul class="dropdown-menu">
<li>Property Management</li>
<li>Buying a Property</li>
<li>Selling a Property</li>
<li class="goleft">home</li>
</li>
</ul>
</div>
</nav>
<!--end nav bar-->
If anyone has any ideas on how to fix this, that would be great. Thanks so much. -Beth
You could try changing the class col-lg-12 by col-md-12 or even col-sm-12.
This should make your navbar adapt better smaller resolutions.
Trying to make my mobile navbar not coming out quite right. Anyone see the problem? I have only a couple months experience, need a quick hand of help. Much appreciated!
As you can see it doesnt display the navbar right at all. The contact page isnt clickable.Its missing the Services link
*******************
NAV MENU MOBILE
*******************
-->
<div class="menu-wrap mobile">
<div class="container">
<div class="row">
<div class="col-sm-3 no-padding">
<img src="img/logo.png" alt="logo" class="logo-menu">
</div>
<div class="col-sm-9 col-lg-7 col-lg-offset-2 no-padding">
<nav class="nav-menu">
<button class="menu-toggle">
<span class="icon"></span>
<span class="icon"></span>
<span class="icon"></span>
</button>
<ul class="main-menu">
<li class="menu-item active menu-item-has-children">
Home
</li>
<li class="menu-item menu-item-has-children">
<a>Hosting</a>
<ul class="sub-menu">
<li class="menu-item">Shared Hosting</li>
<li class="menu-item">Reseller Hosting</li>
<li class="menu-item">Cloud VPS</li>
<li class="menu-item">Dedicated Server</li>
</ul>
</li>
<li class="menu-item">
Domains
</li>
<li class="menu-item menu-item-has-children">
<a href="blog.html>Blog</a>
</li>
<li class="menu-item menu-item-has-children">
<a href="services.html>Services</a>
</li>
<li class="menu-item menu-last">
<a class="menu-item" href="contact.html">Contact</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
navbar
<a href="services.html>Services</a>
should be
Services
You left out the second ".
In those two links...
<a href="blog.html>Blog</a>
<a href="services.html>Services</a>
...the closing quote of the hrefattribute is missing. Should be
Blog
Services
I'm currently stuck, I'm trying to make a div take 100% height with 100vh (position fixed is not an option). It works, but only for the active window, when we scroll, the div stop taking 100% height.
I've searched on the other topics, and I tried min-height : 100vh, also tried put position relative and min-height: 100% on html and body tags, but it doesn't work for me.
Maybe I have to specify that I'm using bootstrap 3.
HTML
<div id="bel-menu" class="col-sm-3 col-md-2 col-lg-2">
<ul id="custom-menu" class="nav nav-pills nav-stacked" role="menu" aria-labelledby="dropdownMenu">
<li role="presentation" class="groupe-icon dropdown-submenu main-menu">
<div class="blue-bar"></div>
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button">Groupe</a>
<div class="menu-arrow"></div>
<ul class="dropdown-menu secondary-menu">
<li class="">Groupe</li>
<li class="">Mission</li>
<li class="">Marques et produits</li>
<li class="">Engagements</li>
<li class="">Temps forts</li>
<li class="">Implantations</li>
<li class="">Bel dans le monde</li>
<li class="">Finance</li>
<li class="">Gouvernance</li>
<li class="">Présenter Bel</li>
</ul>
</li>
<li class="workplace-icon dropdown-submenu main-menu">
<div class="blue-bar"></div>
Workplace
<div class="menu-arrow"></div>
</li>
<li class="documents-icon dropdown-submenu main-menu">
<div class="blue-bar"></div>
Documents
<div class="menu-arrow"></div>
</li>
<li class="moi-chez-bel-icon dropdown-submenu main-menu">
<div class="blue-bar"></div>
Moi chez Bel
<div class="menu-arrow"></div>
</li>
<li class="applications-icon dropdown-submenu main-menu">
<div class="blue-bar"></div>
Applications
<div class="menu-arrow"></div>
</li>
</ul>
<div class="col-sm-3 col-md-2 col-lg-2 nopad open-btn">
<div class="arrow-icon"></div>
</div>
</div>
CSS
#bel-menu {
height: 100vh;
padding: 0;
background-color: #333;
}
Take a look to my project : https://jsfiddle.net/e94wewad/
The div I'm talking about is the one, that is containing the lateral menu.
The menu is taking 100% of the viewport, but when I scroll down, it stops.
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>
I have searched high and low for this, on SO too but didn't find the "correct" answer.
Just figured it out myself.. Thought to share this, hope it helps someone..
Problem with BS3 is that it's Mobile first, which is a good thing, usually.. It's just that I need a few "default" options in the navbar regardless of the collapse state. Just like BS2.
So how can we do this?
One thing is obvious looking at the html code, the .navbar-header stays where it is, it doesn't collapse. Another thing, the magic collapse button has some way of hiding itself, probably CSS but hey, the idea is to abstract this layer so we don't have to worry about it..
But we can take advantage of this, let's place the links I want to show in there, they won't collapse.
What you will see is that your list items will end up vertically, that's not what you want.. So why does it do that?
Well.. If you use Firebug or some other development inspector, you will find that these items have been set to display : block;, that is making them the width of the screen pushing each next item down.
We need to change that behaviour. So let's add a new class to the ul that we can define in our custom CSS. I named it no-collapse but you can name it whatever you want..
<nav role="navigation" class="navbar navbar-default navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" data-toggle="collapse" data-target="#bs-navbar-collapse" class="navbar-toggle">
<span class="sr-only">Hamburger menu</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<!-- THIS IS WHERE THE MAGIC HAPPENS! -->
<ul class="nav navbar-nav no-collapse">
<li>Apple
</li>
<li>Banana
</li>
</ul>
</div>
<!-- THE STUFF IN THIS DIV WILL COLLAPSE.. -->
<div id="bs-navbar-collapse" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown">More Fruits <b class="caret"></b>
<ul class="dropdown-menu">
<li class="dropdown-header">Citrus</li>
<li>
Lemon
</li>
<li>
Orange
</li>
<li class="divider"></li>
<li class="dropdown-header">
Also a fruit
</li>
<li>
Tomato
</li>
</ul>
</li>
<li class="dropdown">Veggies <b class="caret"></b>
<ul class="dropdown-menu">
<li class="dropdown-header">Green stuff</li>
<li>
Spinache
</li>
<li>
Lettuce
</li>
<li class="divider"></li>
<li class="dropdown-header">Other stuff</li>
<li>Carrot
</li>
<li>Romenesko broccoli
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
This works
</li>
</ul>
</div>
</div>
</nav>
You'll need a modification, add a CSS (or LESS/SASS) after the bootstrap style sheets.
Add this CSS:
.no-collapse li, .no-collapse li a
{
text-align : center;
float : none;
display : inline-block;
}
Now in Bootply it would look like this: http://www.bootply.com/render/133885 source here:http://www.bootply.com/133885
Now we can have the healthy Apple and Banana on the screen on our mobile devices without resorting to the hamburger menu!