bootstrap navbar not displaying correctly on tablet - css

I have a little problem, i got bootstrap navbar set up, but when i resize it to the tablet width, menu escapes the navbar and gets into content like shown here:
http://oi57.tinypic.com/2uykv9g.jpg "see the problem"
Is the menu too wide ? Any help how to fix this would be greatly appriciated.
Code here:
<div class="navbar navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="fa fa-bars color-white"></span>
</button>
<a class="navbar-brand" href="index.html" ><img class="img-responsive" src="images/new.jpg"></a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav" >
<li class="active"><i class="fa fa-home"></i></li>
<li>Packages</li>
<li>Examples of webpages</li>
<li>Our Services</li>
<li>Benefits</li>
<li>References</li>
<li>Contact </li>
</ul>
</div><!--/.navbar-collapse -->
</div>
</div>

Ok i fixed it, so in case somebody else is having that problem, all i did was scale down the logo (which was partially the problem) to 80% on devices smaller than 992px, gave it an absolute positioning etc, here is the css:
#navbar-height: 150px;
#navbar-brand-vpadding: 10px;
.navbar-brand img {
height: #navbar-height - #navbar-brand-vpadding * 2;
position: absolute;
top: #navbar-brand-vpadding;
}
#media (max-width: 992px) {
.make-custom-class-here {
width:201px;
height:41px;
}
}

Related

Fb-Like Button on Nav-Bar Right Menu Hangs off Screen When Screen Exceeds 768

Bootstrap newbie question. I am using a variation of ZimSystem's Left-Center-Right Aligned NavBars. I put my Brand on the left.
There are two seemingly related problems.
1) On large screens the fb-like button hangs off the right-hand side of the page.
2) On small screens, the Brand is moved down a couple lines so that the first menu item is concealed by it.
I have tried using absolute positioning in both cases, but that did not resolve the issue.
<nav class="navbar navbar-default navbar-fixed-top navbar-inverse"> <!-- navbar-default removed -->
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<a class="navbar-brand navbar-left katrielsheader" href="#"><img src="images/Katriels_Kleaners_Script.png" alt="Katriels Kleaners"></a>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-center">
<li class="nav-item"> <a class="nav-link" href="#philosophy">Our Philosophy</a> </li>
<li class="nav-item"><a class="nav-link" href="#priceList">Price List</a>. </li>
<li class="nav-item"><a class="nav-link" href="#contactus">Contact Us</a>. </li>
</ul>
<ul class="nav navbar-nav navbar-right">
<div class="fb-like" data-href="http://www.kokleaners.com" data-layout="button_count" data-action="recommend" data-adapt-container-width="true" data-show-faces="false" data-share="true"></div>
</ul>
</div>
</nav>
CSS
#charset "UTF-8";
/* CSS Document */
html, body{
height:100%;
}
.navbar-default {
background-color:#72c5d5;
border-color: #284449;
z-index: 10;
opacity: 0.9;
}
.nav.navbar-nav.navbar-center li a {
color: #254053;
}
.navbar-light .navbar-nav .nav-link:focus, .navbar-light .navbar-nav .nav-link:hover{
color: #EF3927;
}
Here is the code I used for the fb like positioning that did not work.
#media all and (min-width:768){
.navbar-collapse fb-like{
position:absolute;
right:25;
Seems like this should be a pretty simple fix. But I am perplexed.
Here is the bootply.
Next time put it on jsfiddle.net
Replace your facebook div widget with this and it should do the trick. Your width was awkwardly set. So I changed it to 100% and it formatted properly.
<div class="fb-like fb_iframe_widget" data-href="http://www.kokleaners.com"
... " class="" style="border: none; visibility: visible; **width: 100%**; height: 20px;"></iframe></span>
</div>
The problem with the navbar-brand spacing was resolved by moving its placement into div.
See comments below for clarification.
The spacing of the FB-Widget can also be resolved by setting the margins for navbar-right in custom CSS.
.navbar-right{
margin-top: 20px;
margin-right:20px;
}
To improve layout on small screens, move up navbar-brand as so:
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand navbar-left katrielsheader" href="#"><img src="images/Katriels_Kleaners_Script.png" alt="Katriels Kleaners"></a>
</div>

Bootstrap Toggle Open Menu not spanning 100% width of screen

I'm having a bit of a problem with the Bootstrap nav I've placed on a website I'm making.
When collapsed on smaller screens, the drop down navigation menu doesn't span 100% of the screen - It looks as if there's a 1px gap on either side of the menu and I can't seem to figure out how to fix this.
** EDIT **
Due to bad markup in my original post - I've updated this (still having probelems, but this represents my problem better) at JSFIDDLE
<div class="navbar navbar-custom">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navigation">
<span class="fa fa-bars fa-2x"></span> Menu</button>
<span class="logo"> Logo</span>
</div>
<div class="collapse navbar-collapse" id="navigation">
<ul class="nav navbar-nav navbar-right">
<li>Book A Repair </li>
<li>About </li>
<li>How it Works </li>
<li>Testimonals </li>
<li>Contact </li>
</ul>
</div>
</div>
It's happening because of the Bootstrap margin on the .navbar-collapse.. which is a negative margin of 15px. Just move it out a pixel on each side:
.navbar-custom .container >.navbar-collapse {
margin-right: -16px;
margin-left: -16px;
}
Bootply

Full-width secondary navbar inside parent navbar with Bootstrap

I'm trying to create a pretty simple double-navbar effect with Bootstrap. The only problem I have right now is that the second/bottom navbar isn't stretching across the whole browser width. Here's my code...
<nav class="navbar navbar-fixed-top navbar-inverse">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar" style = "line-height: 30px;">
<span class="sr-only">Toggle navigation</span>
<span class="glyphicon glyphicon-menu-hamburger" style="color:#fff;"></span>
</button>
<a class="navbar-brand" href="#" style = "line-height: 30px;">brand</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<!-- <li>Button</li> -->
</ul>
</div><!-- /.nav-collapse -->
<!-- this is the second navbar element that never takes up the full width available-->
<div class="nav navbar-default" style="background-color: #66CCFF;">
<ul class="nav navbar-nav">
<li></li>
<li class="divider-vertical"></li>
<li></li>
<li class="divider-vertical"></li>
<li></li>
</ul>
</div>
</div><!-- /.container -->
</nav><!-- /.navbar -->
I've played with various different navbar types and css styles (e.g. width:100%), but I can't seem to figure out how to make the second navbar (i.e. the one containing the 3 glyphicons) the same width as its parent.
Really appreciate any ideas on what I might be doing wrong!
You need to use container-fluid instead of container since latter has a fixed width.
.container-fluid still contains CSS rules for padding. You may try to overwrite it using custom class.
.container-fluid.no-padding {
padding: 0;
}
.no-padding .navbar-header {
padding-left: 10px; /* Align the Brand text */
}
#media (max-width: 768px) {
.no-padding .navbar-nav {
padding-left: 10px; /* Align the icons on small screens */
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet" />
<nav class="navbar navbar-fixed-top navbar-inverse">
<div class="container-fluid no-padding">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar" style="line-height: 30px;">
<span class="sr-only">Toggle navigation</span>
<span class="glyphicon glyphicon-menu-hamburger" style="color:#fff;"></span>
</button>
<a class="navbar-brand" href="#" style="line-height: 30px;">brand</a>
</div>
<div id="navbar" class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<!-- <li>Button</li> -->
</ul>
</div>
<!-- /.nav-collapse -->
<!-- this is the second navbar element that never takes up the full width available-->
<div class="nav navbar-default" style="background-color: #66CCFF;">
<ul class="nav navbar-nav">
<li>
</li>
<li class="divider-vertical"></li>
<li>
</li>
<li class="divider-vertical"></li>
<li>
</li>
</ul>
</div>
</div>
<!-- /.container -->
</nav>
<!-- /.navbar -->
.navbar > .container {
padding-left: 0;
padding-right: 0;
}
just removing the padding from container changes all the instances of container on your page.
you then want to add padding back to your navbar-header
.navbar > .container {
padding-left: 0;
padding-right: 0;
}
.navbar .navbar-header {
padding: 5px 10px;
}

Nav Bar falls below logo while browser resizing on bootstrap

The top right fixed nav bar for bootstrap come below the logo when resizing the screen resolution. I uploaded the image on https://www.imageupload.co.uk/image/5bDD
<nav class="navbar navbar-fixed-top navbar-inverse" role="navigation" style="border:0; border-radius:0;">
<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" style="padding:2px;" href="index.php"><img src="img/searchimage.png" width="51" height="45" /> </a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li>
<i class="fa fa-home fa-2x"></i>
</li>
<li>
AboutUs
</li>
...
...
...
</ul>
</div>
</nav>
Please let me know how to solve this...
Thanks
You need to use media queries to specify a smaller font-size when the screen is smaller. Something like this:
#media (max-width: 900px) {
.navbar-inverse li a {
fonts size: 10px;
}
}
The 900px and 10px are for example purposes so you will have to check out which width and font-size will fix the layout problem.
Also, remove the inline-style padding for your list-item as that is not necessary for aligning the links

Bootstrap creating extra padding on column in row

Let me preface this by saying I am relatively new to bootstrap and possibly not udnerstanding the row/column layouts properly.
The layout I am working on can be seen here: http://jsfiddle.net/5NFXY/ (code pasted below)
The 'sidebar' on the right is where the problem is occurring. I have a .col-md-9 and a .col-md-3 enclosed withing a .row, but for some reason the right side of the sidebar is not lining up properly with its container. After playing around with this for quite some time I have found that if I remove margin-right: -15px; from the .row the problem goes away, but surely this isn't' the proper solution and I have mucked something up along the way. My question is, have I done something wrong in my HTML or is the proper solution really to manually override that margin-right: -15px;?
HTML
<body>
<div class="container">
<div class="logo-header">
<h1>Header</h1>
<h4>Subheader</h4>
</div>
<div class="inner-container clearfix">
<!-- Static navbar -->
<div class="navbar navbar-default" role="navigation">
<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>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
Operations <b class="caret"></b>
<ul class="dropdown-menu">
<li class="dropdown-header">Get Started</li>
<li>Start New</li>
<li>View All</li>
<li class="divider"></li>
<li class="dropdown-header"> Settings</li>
<li>Manage Types</li>
<li>Manage Types</li>
</ul>
</li>
<li class="dropdown">
Utilities <b class="caret"></b>
<ul class="dropdown-menu">
<li>Forums</li>
<li class="divider"></li>
<li>Distance</li>
</ul>
</li>
<li class="dropdown">
Administration <b class="caret"></b>
<ul class="dropdown-menu">
<li>News</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
Alts <b class="caret"></b>
<ul class="dropdown-menu">
<li>1</li>
<li>2</li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
<div class="row">
<div class="col-md-9">
<div class="wrath-content-box news-post">
<h1>Title Bar</h1>
<p>This example is a quick exercise to illustrate how the default, static navbar and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p>
<p>
<a class="btn btn-lg btn-primary" href="" role="button">View navbar docs »</a>
</p>
</div>
<div class="wrath-content-box news-post">
<h1>Title Bar</h1>
<p>This example is a quick exercise to illustrate how the default, static navbar and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p>
<p>
<a class="btn btn-lg btn-primary" href="" role="button">View navbar docs »</a>
</p>
</div>
<div class="wrath-content-box news-post">
<h1>Title Bar</h1>
<p>This example is a quick exercise to illustrate how the default, static navbar and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p>
<p>
<a class="btn btn-lg btn-primary" href="" role="button">View navbar docs »</a>
</p>
</div>
<div class="wrath-content-box news-post">
<h1>Title Bar</h1>
<p>This example is a quick exercise to illustrate how the default, static navbar and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p>
<p>
<a class="btn btn-lg btn-primary" href="" role="button">View navbar docs »</a>
</p>
</div>
</div>
<div class="col-md-3 wrath-content-box">
<h1>Title Bar</h1>
<p>This example is a quick exercise to illustrate how the default, static navbar and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p>
<p>
<a class="btn btn-lg btn-primary" href="" role="button">View navbar docs »</a>
</p>
</div>
</div>
<footer class="wrath-content-box">
Footer tagline ©
</footer>
</div> <!-- /inner-container -->
</div> <!-- /container -->
</body>
CSS
body {
padding-top: 20px;
padding-bottom: 20px;
background: url('../img/wh-background-1.jpg') center center no-repeat fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.navbar {
margin-bottom: 20px;
}
.logo-header {
color: #FFF;
}
.logo-header h1 {
margin-bottom: 0;
}
.logo-header h4 {
margin-top: 0;
margin-bottom: 20px;
}
footer {
margin-top: 20px;
}
.inner-container {
background: rgba(119, 119, 119, .5);
border-radius: 6px;
padding: 20px;
}
.wrath-content-box {
border-color: #e7e7e7;
background-color: #f8f8f8;
border-radius: 6px;
padding: 15px;
}
.news-post {
margin-bottom: 20px;
}
Using: Bootstrap 3.0.3 + Jquery 1.10.1
You've combined your custom class wrath-content-box with the bootstrap col-md-3 class and the padding on your class is overriding the Bootsrap grid padding.
You just need to put your class in a separate <div> inside the bootstrap one like you did in the first column.
<div class="col-md-3">
<div class="wrath-content-box">
...
</div>
</div>
Demo

Resources