How to make 100% width of the search input in navbar?
The field is limited in width:
<nav class="navbar navbar-light navbar-dark bg-inverse">
<a class="navbar-brand" href="#">Navbar</a>
<ul class="nav navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Features</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Pricing</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
</ul>
<ul class="nav navbar-nav pull-xs-right">
<li class="nav-item">
<form class="form-inline ">
<input class="form-control" type="text" placeholder="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</li>
<li class="nav-item">
<a class="nav-link" href="#">User Name</a>
</li>
</ul>
</nav>
Here is the fiddle:
https://jsfiddle.net/Dieselnick/tdoz2o4d/
Updated 2019
As of Bootstrap 4 the Navbar is flexbox so creating a full-width search input is easier. You can simply use w-100 and d-inline utility classes:
<form class="mx-2 my-auto d-inline w-100">
<div class="input-group">
<input type="text" class="form-control" placeholder="...">
<span class="input-group-append">
<button class="btn btn-outline-secondary" type="button">GO</button>
</span>
</div>
</form>
http://www.codeply.com/go/sbfCXYgqoO
Here's another example with the search input outside of the collapsing navbar:
<!-- search input not in navbar collapse -->
<nav class="navbar navbar-expand-md navbar-dark bg-dark">
<div class="d-flex flex-grow-1">
Codeply
<form class="mr-2 my-auto w-100 d-inline-block order-1">
<div class="input-group">
<input type="text" class="form-control border border-right-0" placeholder="Search...">
<span class="input-group-append">
<button class="btn btn-outline-light border border-left-0" type="button">
<i class="fa fa-search"></i>
</button>
</span>
</div>
</form>
</div>
<button class="navbar-toggler order-0" type="button" data-toggle="collapse" data-target="#navbar7">
<span class="navbar-toggler-icon"></span>
</button>
<div class="navbar-collapse collapse flex-shrink-1 flex-grow-0 order-last" id="navbar7">
<ul class="navbar-nav">
..
</ul>
</div>
</nav>
http://www.codeply.com/go/sbfCXYgqoO
And, finally another example that varies the width of the search on desktop/mobile (only full width on mobile) from my answer here
Bootstrap 3 (original answer)
You can use the text-truncate hack on the last navbar li like this..
<li class="text-truncate">
<form class="input-group">
<input class="form-control" name="search" placeholder="Search Here" autocomplete="off" autofocus="autofocus" type="text">
<div class="input-group-btn">
<button class="btn btn-outline-success" type="submit">Search</button>
</div>
</form>
</li>
In Bootstrap 4, text-truncate will set:
overflow: hidden;
white-space: nowrap;
This enables the search form to fill the remaining width and not wrap.
Demo http://www.codeply.com/go/22naSu3c0E
Another option is to use table-cell:
<form>
<div class="table-cell"> </div>
<div class="table-cell fill-width">
<input class="form-control" name="search" placeholder="Search Here" autocomplete="off" autofocus="autofocus" type="text">
</div>
<div class="table-cell">
<button class="btn btn-outline-success" type="submit">Search</button>
</div>
</form>
http://www.codeply.com/go/JdbPvotSXg
Related
MY body just wont alight with the nav. there are some margins on the container, when I try to set up mx-0 the space just goes to the left. it is just no taking the whole with of the body. I am not sure what I am missing. I tried putting the nav inside the main container but still doesnt work.
[![<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
LightQUIZ
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse px-3 justify-content-between" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="#"> HOME</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">CATEGORIES</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">TOP QUIZES</a>
</li>
</ul>
<div class="d-flex flex-column flex-md-row align-items-start">
<form class="form-inline mx-lg-2 d-flex flex-row">
<input class="form-control px-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
<button class="btn btn-success mx-md-2 my-sm-2 my-md-0">LOGIN</button>
<button class="btn btn-danger">SIGNUP</button>
</div>
</div>
</nav>
<main class="container">
<section class="home-header row pt-4">
<div class=" col-md-8 jumbotron">
<h2 class="display-5">Hello, world!</h2>
<p class="lead">This is a simple hero unit, a simple jumbotron-style component for calling extra attention to
featured content or information.</p>
<hr class="my-4">
<p>It uses utility classes for typography and spacing to space content out within the larger container.</p>
<p class="lead">
<a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a>
</p>
</div>
<div class="col-md-4 d-flex flex-column">
<h4 class="text-center">LightQuiz LeaderBoard</h4>
<ul class="list-group leaderboard">
<li class="list-group-item d-flex justify-content-between align-items-center">
ABC
<span class="badge badge-pill badge-danger">55</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
ABC
<span class="badge badge-primary badge-pill">55</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
ABC
<span class="badge badge-primary badge-pill">55</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
ABC
<span class="badge badge-primary badge-pill">55</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
ABC
<span class="badge badge-primary badge-pill">55</span>
</li>
</ul>
</div>
</section>
</main>][1]][1]
The purpose of the container is so it will add space to either side in case the screen becomes too large in width. Try making your screen really small in width, then resize until it becomes large. It should have breakpoints where the spacing will change.
The nav element you have uses other classes that do not change the side spacing the same way as the container.
If you do not want space on either side of you main element, simply remove the container class.
If you want to make the navbar adopt the same side spacing as the main element, add the container class to the nav element.
Updated answer after reading your comment here:
Bootstrap also provides a "fluid" container class that makes it span "the entire width of the viewport". From the latest documentation for version 5:
<div class="container-fluid">
Simply, use class container-fluid instead of container on the main body.
Example:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#4.6.0/dist/js/bootstrap.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#4.6.0/dist/css/bootstrap.min.css" rel="stylesheet"/>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
LightQUIZ
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse px-3 justify-content-between" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="#"> HOME</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">CATEGORIES</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">TOP QUIZES</a>
</li>
</ul>
<div class="d-flex flex-column flex-md-row align-items-start">
<form class="form-inline mx-lg-2 d-flex flex-row">
<input class="form-control px-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
<button class="btn btn-success mx-md-2 my-sm-2 my-md-0">LOGIN</button>
<button class="btn btn-danger">SIGNUP</button>
</div>
</div>
</nav>
<main class="container-fluid">
<section class="home-header row pt-4">
<div class=" col-md-8 jumbotron">
<h2 class="display-5">Hello, world!</h2>
<p class="lead">This is a simple hero unit, a simple jumbotron-style component for calling extra attention to
featured content or information.</p>
<hr class="my-4">
<p>It uses utility classes for typography and spacing to space content out within the larger container.</p>
<p class="lead">
<a class="btn btn-primary btn-lg" href="#" role="button">Learn more</a>
</p>
</div>
<div class="col-md-4 d-flex flex-column">
<h4 class="text-center">LightQuiz LeaderBoard</h4>
<ul class="list-group leaderboard">
<li class="list-group-item d-flex justify-content-between align-items-center">
ABC
<span class="badge badge-pill badge-danger">55</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
ABC
<span class="badge badge-primary badge-pill">55</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
ABC
<span class="badge badge-primary badge-pill">55</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
ABC
<span class="badge badge-primary badge-pill">55</span>
</li>
<li class="list-group-item d-flex justify-content-between align-items-center">
ABC
<span class="badge badge-primary badge-pill">55</span>
</li>
</ul>
</div>
</section>
</main>
</body>
https://jsfiddle.net/mkpu9wcd/
For more info, read: https://getbootstrap.com/docs/5.0/layout/containers/
This navigation bar uses Bootstrap 4. For medium screens (768px to 991px), I would like the search bar and button to be moved to the second line, as it is on large screens and above. Currently, on medium screens the search bar squishes up next to the other navigation links:
How it looks on large/extra large screens:
Updated code per first answer suggestion:
<nav class="navbar navbar-expand-md navbar-fixed-top navbar-dark bg-navbar">
<div class="container">
<a class="navbar-brand" href="/" style="align-children: middle">
<span class="" aria-hidden="true"></span>
Example
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#site-nav" aria-expanded="false" aria-label="Toggle navigation">
<span class="sr-only">Toggle navigation</span>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse ml-auto" id="site-nav">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="/">Home
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/agencies/">Agencies</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/meetings/">Meetings</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/agenda/">Agenda</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/documents/">Documents</a>
</li>
</ul>
<form class="form-inline mt-3 mb-3" role="search" action="/search/" method="post">
<div class="btn-group">
<input type="text" name="request" class="form-control" placeholder="Search Documents">
<button type="submit" class="btn search-button">Search</button>
</div>
</form>
</div>
</div>
</nav>
You can use the responsive flexbox direction utils. For example, flex-column flex-xl-row on the navbar-collapse.
<nav class="navbar navbar-expand-md fixed-top navbar-dark bg-dark">
<div class="container">
<a class="navbar-brand" href="/" style="align-children: middle">
<span class="" aria-hidden="true"></span>
Example
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#site-nav" aria-expanded="false" aria-label="Toggle navigation">
<span class="sr-only">Toggle navigation</span>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse ml-auto align-items-start align-items-xl-center flex-column flex-xl-row" id="site-nav">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="/">Home
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/agencies/">Agencies</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/meetings/">Meetings</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/agenda/">Agenda</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/documents/">Documents</a>
</li>
</ul>
<form class="form-inline ml-2" role="search" action="/search/" method="post">
<div class="form-group">
<input type="text" name="request" class="form-control" placeholder="Search Documents">
</div>
<button type="submit" class="btn search-button">Search</button>
</form>
</div>
</div>
</nav>
https://www.codeply.com/go/ZEyl77GzA8
Note: You're using navbar-expand-md so the Navbar will collapse into the toggler on sm. If you want to instead show the stacked menu/form on md you should reduce the navbar expand to sm.
Also see: Bootstrap 4 navbar with 2 rows
Put the contents of the search form in a btn-group, which should keep them together:
<form class="form-inline mt-3 mb-3" role="search" action="/search/" method="post">
<div class="btn-group" role="group" aria-label="Basic example">
<input type="text" name="request" class="form-control" placeholder="Search Documents">
<button type="submit" class="btn search-button">Search</button>
</div>
</form>
<header class="navbar navbar-static-top bs-docs-nav" id="top" role="banner">
<div id="header" class=" container-fluid">
<div class="navbar-header">
<button class="navbar-toggle collapsed" type="button" data-toggle="collapse" data-target=".bs-navbar-collapse">
<span class="sr-only">Menu</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<img title="DropInn" src="logo/logo.png" width="137" height="45">
</div>
<nav class="collapse navbar-collapse bs-navbar-collapse" role="navigation">
<ul class="nav navbar-nav">
<li>
<div class="search" style="">
<form id="search_form1" action="http://products.cogzidel.com/airbnb-clone/search" method="post" class="searchform_head">
<i class="fa fa-search heaericon"></i>
<input type="text" id="searchTextField" name="searchbox" class="searchbox" value="Where are you going?" onblur="if (this.value == ''){this.value = 'Where are you going?'; }" onfocus="if (this.value == 'Where are you going?') {this.value = ''; }" onKeyPress="return disableEnterKey(event)" placeholder="Where are you going?" />
<div id="map-canvas"></div>
<input type="hidden" id="lat" name="lat" value="">
<input type="hidden" id="lng" name="lng" value="">
<div class='advanced_search' id="advanced_search" style='display: none; position: absolute;
z-index: 2147483647; background:#FCFCFC; border: 1px solid #CCCCCC; padding: 10px; opacity: 1;width: 240px;top:37px;'>
<label class="checkin_search">
Check in
<div id="checkinWrapper" class="input-wrapper">
<input id="checkindate2" class="check_wrap checkin search-option ui-datepicker-target" type="text" placeholder="Check in" name="checkin" autocomplete="off" readonly>
</div>
</label>
<label class="checkout-detail_search">
Check out
<div id="checkoutWrapper" class="input-wrapper">
<input id="checkoutdate2" class="check_wrap checkout search-option ui-datepicker-target" type="text" placeholder="Check out" name="checkout" autocomplete="off" readonly>
</div>
</label>
<div class="clearfix"></div>
<p class="filter_header">Room type</p>
<!-- Search filter content is below this -->
<div class="clearfix"></div>
<ul class="search_filter_content">
<li class="clearfix checkbox">
<input class="checkbox_filter" type="checkbox" value="Entire home/apt" name="room_types1" id="room_type_0">
<label class="checkbox_list" for="room_type_0"> Entire home/apt</label>
</li>
<li class="clearfix checkbox">
<input class="checkbox_filter" type="checkbox" value="Private room" name="room_types2" id="room_type_1">
<label class="checkbox_list" for="room_type_1"> Private room</label>
</li>
<li class="clearfix checkbox">
<input class="checkbox_filter" type="checkbox" value="Shared room" name="room_types3" id="room_type_2">
<label class="checkbox_list" for="room_type_2">Shared room</label>
</li>
</ul>
<div class="clearfix"></div>
<!-- <button id="submit_location" class="btn_dash" style=" font-size: 12px;margin: 10px 0; padding: 5px 11px;" type="submit" value="Search" name="Submit" >-->
<!--<i class="fa fa-search submitloc"></i>-->
<!--<img src="http://products.cogzidel.com/airbnb-clone//css/templates/blue/images/search_icon1.png" />-->
<button id="submit_location" class="btn_dash" type="submit" value="Search" name="Submit">
<i class="fa fa-search submitloc"></i>
<!--<img src="http://products.cogzidel.com/airbnb-clone//css/templates/blue/images/search_icon1.png" />-->
Find A Place </button>
<label class="btn_dash" id="close_search">
Close </label>
</div>
</form>
</div>
</li>
</form>
</li>
<li id="subnavigation" class="dropdown browse-dropdown">
<a class="dropdown-toggle header_link" href="#" data-toggle="dropdown">Browse <span class="caret"></span></a>
<ul class="dropdown-menu sub-menu browse-submenu">
<li><!-- <i class="icon-popular"> </i>--> <i class="fa fa-heart"></i> Popular</li>
<li><a class="friends" href="home/friends/index.html"><i class="icon-friends"> </i> Friends</a></li>
<li><a class="map-neigh" href="home/neighborhoods/index.html"><!--<i class="icon-neighborhoods"> </i> --> <i class="fa fa-map-marker"></i>Neighborhoods</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="rightsign sign1">Sign Up</li>
<li class="rightsign sign1">Sign In</li>
<li id='view_help' style='float:left;'>
<li id='view_help' class="dropdown browse-dropdown help_book">
<a class="dropdown-toggle view_help1" data-toggle="dropdown" href="#">Help <span class="caret"></span></a>
<ul class="dropdown-menu sub-menu browse-submenu">
<li>How do i sign up?</li>
<li> Need help on this page?
</li>
</ul>
</li>
<li class="lisyourspace"> <a class="btn yellow" href="rooms/new.html"><span>List Your Space</span></a> </li>
<!--<li class="listyourspace_menu"> <a class="yellow btn" href="http://products.cogzidel.com/airbnb-clone/rooms/new"><span>List Your Space</span></a> </li>-->
</nav>
</div>
</header>
I need CSS code for this display exact like Airbnb home page. Somebody please help to get this. I tried so many times, but failed to design that properly. How to do the full width grid system and how to code the CSS files?
First, you should try to add your background elements. Then, use basic css to make it fit the whole page width with repeat or not (depending on your background image)
Then, about the "full width grid system", bootstrap has many classes that fit your requirements like 'col-lg-** col-md-** col-sm-** col-xs-**', you should have a look at this :
http://getbootstrap.com/css/#grid
Your code is just a bit too generic. But this "bootply" is a good starting point for you :
http://www.bootply.com/b1SPDA3GOn
Hope it helps!
You can see it live here.
Here is a screenshot on mobile:
Here is the sterilized HTML:
<header class="header">
<hgroup class="pull-left">
<h1 class="site-title">
<a rel="home" title="Von" href="index.html">
<i class="fa fa-lemon-o"></i> Von
</a>
</h1>
</hgroup>
<div id="togglesidebar" class="btn btn-primary pull-right">
<i class="fa fa-bars"></i>
</div>
<!-- Single button -->
<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
Action <span class="caret"></span>
</button>
<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>
</div>
<!-- Search Bar -->
<div class="container">
<div class="row">
<div class="col-xs-6 col-xs-offset-2">
<div class="input-group">
<div class="input-group-btn search-panel">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span id="search_concept">Filter by</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>Contains</li>
<li>It's equal</li>
<li>Greather than ></li>
<li>Less than < </li>
<li class="divider"></li>
<li>Anything</li>
</ul>
</div>
<input type="hidden" name="search_param" value="all" id="search_param">
<input type="text" class="form-control" name="x" placeholder="Search term...">
<span class="input-group-btn">
<button class="btn btn-default" type="button"><span class="glyphicon glyphicon-search"></span></button>
</span>
</div>
</div>
</div>
</div> <!-- /search-bar -->
</header> <!-- /header -->
In the live version, the logo is 153px X 50px.
Update 1:
After Darshak's suggestion, this is what the mobile version looks like. Better, but still needs adjustment.
try this. i try to responsive look to your design and some class modified in your structure.
i put this structure online at your given link.
<header class="header clearfix">
<div class="row masthead clearfix">
<hgroup class="col-xs-6 col-sm-6 col-md-3 col-lg-3">
<div class="site-title">
<a href="/">
<img alt="Ognrlogo" height="50" src="/assets/ognrlogo-232e94e86f40eeb3021490f5cf1e1a48.png" width="153" class="img-responsive" style="
margin: 0;
">
</a>
<br>
<span class="">On The Ground News Report</span>
</div>
</hgroup>
<div class="col-xs-6 col-sm-6 col-md-2 col-lg-2 masthead-group-2 text-right">
<ul class="nav navbar-nav navbar-right">
<!-- <li class="dropdown"> -->
<!-- <li> </li> -->
<!-- <li> </li> -->
<!-- </li> -->
<!-- <li> </li> -->
<!-- <li> </li> -->
<div class="dropdown">
<button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
Login & Join
<span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
<li role="presentation"><i class="fa fa-sign-in"></i> Login
</li>
<li role="presentation"><i class="fa fa-sign-out"></i> Join
</li>
</ul>
</div>
</ul>
</div>
<!-- /dropdown-parent-div -->
<!-- /search-box-parent -->
<div class="hidden-sm hidden-xs col-md-4 col-lg-4 masthead-group-2">
<div class="input-group">
<div class="input-group-btn search-panel">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span id="search_concept">Filter by</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>Contains
</li>
<li>It's equal
</li>
<li>Greather than >
</li>
<li>Less than <
</li>
<li class="divider"></li>
<li>Anything
</li>
</ul>
</div>
<input type="hidden" name="search_param" value="all" id="search_param">
<input type="text" class="form-control" name="x" placeholder="Search term...">
<span class="input-group-btn">
<button class="btn btn-default" type="button"><span class="fa fa-search"></span>
</button>
</span>
</div>
</div>
<div class="hidden-sm hidden-xs col-md-3 col-lg-3 masthead-group-3">
<!-- <div id="togglesidebar" class="btn btn-primary pull-right">
<i class="fa fa-bars"></i>
</div> -->
<div id="togglesidebar" class="pull-right">
<button class="btn btn-default btn-lg btn-primary"><i class="fa fa-child"></i> Submit News</button>
</div>
</div>
</div>
<div class="row clearfix">
<div class="col-xs-12 col-sm-6 hidden-md hidden-lg masthead-group-2">
<div class="input-group">
<div class="input-group-btn search-panel">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span id="search_concept">Filter by</span> <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">
<li>Contains
</li>
<li>It's equal
</li>
<li>Greather than >
</li>
<li>Less than <
</li>
<li class="divider"></li>
<li>Anything
</li>
</ul>
</div>
<input type="hidden" name="search_param" value="all" id="search_param">
<input type="text" class="form-control" name="x" placeholder="Search term...">
<span class="input-group-btn">
<button class="btn btn-default" type="button"><span class="fa fa-search"></span>
</button>
</span>
</div>
</div>
<div class="col-xs-12 col-sm-6 hidden-md hidden-lg masthead-group-3">
<!-- <div id="togglesidebar" class="btn btn-primary pull-right">
<i class="fa fa-bars"></i>
</div> -->
<div id="togglesidebar" class="pull-right">
<button class="btn btn-default btn-lg btn-primary"><i class="fa fa-child"></i> Submit News</button>
</div>
</div>
</div>
<!-- /row -->
</header>
Look at this and modify your source code according to that
http://getbootstrap.com/components/#navbar
You can do like this , to look it better on mobile devices.
<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 collapsed" 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 <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>
<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>
I've been trying to make a responsive navbar with columns but I can't manage to react well to the different sizes I've trying al lot of things: column-offset, contaniers, paddings... but I can't get a decent result. Here it is what I managed to do so far:
<nav class="navbar navbar-default ">
<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 class="navbar-collapse collapse" style="height: 0px;">
<div class="row show-grid">
<div class=" col-xs-8 col-md-6 col-md-offset-2" >
<ul class="nav navbar-nav" id="altre">
<li>Shop
</li>
<li>Style Guide
</li>
<li>Be a man
</li>
</ul>
</div>
<div class=" col-xs-4 col-md-4">
<ul class="nav navbar-nav hidden-xs" id="login">
<li class="dropdown">
<a class="dropdown-toggle" href="#" data-toggle="dropdown">Login</a>
<div class="dropdown-menu">
<form class="navbar-form" role="form">
<p><input class="form-control" type="text" placeholder="E-mail"></p>
<p><input class="form-control" type="password" placeholder="Contrasenya"></p>
<button type="button" class="btn btn-primary">Sign in</button>
<button type="button" class="btn btn-success">Log in</button>
</form>
</div>
</li>
</ul>
<form class="navbar-form text-center visible-xs" role="form">
<p><input class="form-control" type="text" placeholder="E-mail"></p>
<p><input class="form-control" type="password" placeholder="Contrasenya"></p>
<button type="button" class="btn btn-primary">Sign in</button>
<button type="button" class="btn btn-success">Log in</button>
</form>
</div>
</div>
</div>
</nav>
At first sight it seems to be working right but when you resize you see the difference between the right and left margin.
I'm very lost at this point, anyone knows a clean way to have a good result?
here the files if you don't want to download one by one:
https://drive.google.com/file/d/0BwOBDBZckmYwZ20tLTRQdFI3a3c/edit?usp=sharing
thanks
You need to use .container class in divs before rows, the problem that you have seems to be using percentages in margin-left.
<div class="container"><!-- container -->
<div class="row">
<ul>...
</div>
</div>
See: http://jsfiddle.net/uFwnU/