Overlapping rows in Twitter bootstrap - css

I have got a problem with rows which are overlapping in this following code:
<header>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="navbar navbar-fixed-top ">
<a class="navbar-brand" rel="home" href="#" title="Buy Sell Rent Everyting">
Site.com
</a>
<ul class="nav navbar-nav navbar-right">
<li>Contact Us</li>
<li>NL</li>
<li>ENG</li>
<li>SP</li>
</ul>
</div>
</div>
</div>
</div>
</header>
<div class="row">
<div class="col-md-6"><h1>This is my header</h1></div>
<div class="col-md-6"><img src="img/MyPicture.JPG" height="300"></div>
</div>
In my browser the last rows lies over the navbar. Could it be that it has got something to do with the second row being outside the container? If so where should I define the container.
Here is the jsfiddle text: http://jsfiddle.net/L9GJE/

Wrap <div class="row"> with a <div class="container">
e.g.
<div class="container">
<div class="row">
....
</div>
</div>
So whenever you use the navbar you'll need to keep in mind that it is fixed and you will need to add margin or padding from the top so your rows won't overlap.

Your navbar is fixed, so, you need to add margin-top to second row.

Your navbar was not made correctly, here is the correct usage of the navbar class:
<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>
</ul>
<ul class="nav navbar-nav navbar-right">
<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>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div class="container">
<div class="row">
<div class="col-md-6">
<h1>This is my header</h1>
</div>
<div class="col-md-6">
</div>
</div>
</div>

Related

Bootstrap Brand Image Showing too large

Perhaps its my css but my code should show the image in the header at a fixed size. However, it looks like it may be outside of the div. Heres the code.
<div class="row">
<div class="col-md-12 top navbar-fixed-top">
<div class="col-md-6">
<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="#"><img class="img-responsive" src="http://dev-httpwwwrestechsyscom.pantheonsite.io/sites/all/themes/myWay/logo.png"></a>
</div></nav></div>
<div class="col-md-6">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<ul class="menu"><li class="first expanded dropdown active">About Us <span class="caret"></span><ul class="dropdown-menu"><li class="first leaf active">Mission Statement</li>
<li class="leaf">Meet Our Team</li>
<li class="leaf">Testimonials</li>
<li class="last leaf">Sample Athletes Profile</li>
</ul></li>
<li class="leaf">Eligibility</li>
<li class="expanded dropdown">Recruiting <span class="caret"></span><ul class="dropdown-menu"><li class="first leaf">Recruiting FAQ</li>
<li class="last leaf">Recruiting Info</li>
</ul></li>
<li class="last leaf">Services</li>
</ul><li class="active"></li>
</ul>
</div>
</div></div></div>
You can fix it in this way. Just add desired height to brand image and width will be auto based on height. For example:
.navbar-brand img {
height: 30px;
}
You can add a max-height: 100% to the .navbar-brand img element and it will contain the image inside of .navbar-brand. The height of .navbar-brand is 50px from bootstrap's css, so to make it bigger than that, change the height of .navbar-brand
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<style>
.navbar-brand img {
max-height: 100%;
}
/* add/change this if you want to make the navbar brand area bigger */
.navbar-brand {
height: 100px;
}
</style>
<div class="row">
<div class="col-md-12 top navbar-fixed-top">
<div class="col-md-6">
<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="#"><img class="img-responsive" src="http://dev-httpwwwrestechsyscom.pantheonsite.io/sites/all/themes/myWay/logo.png"></a>
</div>
</nav>
</div>
<div class="col-md-6">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<ul class="menu">
<li class="first expanded dropdown active">About Us <span class="caret"></span>
<ul class="dropdown-menu">
<li class="first leaf active">Mission Statement</li>
<li class="leaf">Meet Our Team</li>
<li class="leaf">Testimonials</li>
<li class="last leaf">Sample Athletes Profile</li>
</ul>
</li>
<li class="leaf">Eligibility</li>
<li class="expanded dropdown">Recruiting <span class="caret"></span>
<ul class="dropdown-menu">
<li class="first leaf">Recruiting FAQ</li>
<li class="last leaf">Recruiting Info</li>
</ul>
</li>
<li class="last leaf">Services</li>
</ul>
<li class="active"></li>
</ul>
</div>
</div>
</div>
</div>

Why is my navbar menu cut off?

I've been given a web site to modify, which was built using Bootstrap v3.3.7. It includes a navbar (HTML below) which looks fine. However, I need to add a dropdown item to the navbar, which I did following the instructions on the Bootstrap page. The HTML is basically the same as I've used elsewhere without problems.
However, when I click on the dropdown in this case, the menu is cut off...
You can just see the top of the first item in the menu, but nothing more.
Anyone able to explain why this is happening? Here is the HTML for the navbar...
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="row">
<div class="col-md-4 col-sm-4">
<div class="site-title">
<h3>My web site</h3>
</div>
</div>
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<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="col-md-8 col-sm-8 navbar-style">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li class="dropdown">
Colours <b class="caret"></b>
<ul class="dropdown-menu">
<li>abc</li>
<li>def</li>
<li>ghi</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
I can't comment yet so I'll put my comment here with suggestion
neophyte shows that the code is working fine.. check your css style if you have overflow: hidden or something on your header
I'm not sure if the black background is part of your edit with menu cut off here if not, then your header has overflow
show us your css style too
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="row">
<div class="col-md-4 col-sm-4">
<div class="site-title">
<h3>My web site</h3>
</div>
</div>
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<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="col-md-8 col-sm-8 navbar-style">
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
<li class="dropdown">
Colours <b class="caret"></b>
<ul class="dropdown-menu">
<li>abc</li>
<li>def</li>
<li>ghi</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
For me it works fine . check out above snippet. I think it's a cdn problem. you might have included it twice in your page.

Bootstrap + Mobile Menu Overlay

I have a page that uses Bootstrap 3. In this page, I have a navbar that's defined like the following:
<nav class="navbar" style="background-color:orange;">
<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="color:#000 !important;">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar" style="color:#000;"></span>
<span class="icon-bar" style="color:#000;"></span>
<span class="icon-bar" style="color:#000;"></span>
</button>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a href="/home" class="dropdown-toggle navbar-dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
Home <span class="caret"></span></a>
<ul class="dropdown-menu">
<li>help</li>
<li>contact</li>
</ul>
</li>
</ul>
<div class="navbar-right">
<div class="visible-xs">
<div class="row">
<div class="col-xs-6">
2016
<ul class="dropdown-menu dropdown-menu-right">
<li>Q1</li>
<li>Q2</li>
<li>Q3</li>
<li>Q4</li>
</ul>
</div>
<div class="col-xs-6">
2017
<ul class="dropdown-menu dropdown-menu-right">
<li>Q1</li>
<li>Q2</li>
<li>Q3</li>
<li>Q4</li>
</ul>
</div>
</div>
</div>
<div class="hidden-xs">
<ul class="nav navbar-nav">
<li>
2016
<ul class="dropdown-menu dropdown-menu-right">
<li>Q1</li>
<li>Q2</li>
<li>Q3</li>
<li>Q4</li>
</ul>
</li>
<li>
2017
<ul class="dropdown-menu dropdown-menu-right">
<li>Q1</li>
<li>Q2</li>
<li>Q3</li>
<li>Q4</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
</nav>
The navbar looks and works like I want on bigger screens. But on mobile, it doesn't work correctly. As you can see in this Bootply, the nav menu pushes the main content (the Lorem Ipsum) down. However, I want the nav menu to appear on top of the content, so that the mobile nav appears on top of the Lorem Ipsum stuff. What am I doing wrong?
Do you want like this:
http://www.bootply.com/9OB6nhtg4i#
#media (max-width:768px) {
.navbar {
position: absolute;
}
}
Add this css and try.
U need to use navbar-fixed-top class and set top padding for main block:
main {
padding-top: 60px;
}
http://www.bootply.com/aROSWOLDZY

Bootstrap - Right Align Icon Buttons in Header on Mobile

I am building a responsive site with Bootstrap. The site has a fixed nav bar. It works great on desktop. However, when the site is running on a mobile device, the icons in the upper right disappear. My code looks like this:
<div id="nav" class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<img src="/logo.png">
</div>
<div class="navbar-header navbar-right">
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a id="viewButton" data-toggle="tooltip" data-placement="bottom"><span class="glyphicon glyphicon-print"></span></a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-arrow-right"></span>
</a>
<ul class="dropdown-menu" role="menu">
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
How can I right-align buttons in the navbar when in mobile view?
Thanks!
Hi you have to remove the collapse classes from the div.
http://www.bootply.com/F6jMrwYOQQ#
<div id="nav" class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<img src="/logo.png">
</div>
<div class="navbar-header navbar-right">
<div class="navbar">
<ul class="nav navbar-nav navbar-right">
<li><a id="viewButton" data-toggle="tooltip" data-placement="bottom"><span class="glyphicon glyphicon-print"></span></a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" aria-haspopup="true" aria-expanded="false">
<span class="glyphicon glyphicon-arrow-right"></span>
</a>
<ul class="dropdown-menu" role="menu">
</ul>
</li>
</ul>
</div>
</div>
</div>
You can try to remove the collapse class here
<div class="navbar-collapse collapse">

Centering menu nav-bar items in center of newvar twitter bootstrap

This is what I have. How do I center these 3 navbar items to the center of the page without messing everything up in mobile view? Thanks.
Any CSS tricks?
<div class ="container" id = "main">
<div class="navbar navbar-fixed-top">
<div class="container">
<!-- .btn-navbar is used as the toggle for collapsed navbar content -->
<button class="navbar-toggle" data-target=".navbar-responsive-collapse"
data-toggle="collapse" type="button">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="nav-collapse collapse navbar-responsive-collapse">
<ul class="nav navbar-nav">
<li class="active">
About us
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle"
data-toggle="dropdown">Services <strong class="caret"></strong></a>
<li>
<ul class="nav navbar-nav">
<li class="active">
Contact
</li>
</div><!-- end nav-collapse -->
</div><!-- end container -->
</div><!-- end navbar -->

Resources