Aligning search bar for mobile and desktop with bootstrap 3.3 - html

I want my search box to appear in the nav bar on the desktop and in mobile. Currently, when I reduce the width, the search bar drops to the next line. I can't figure out how to keep it flush with the nav bar.
Here's the code: http://plnkr.co/edit/Unr6MEiIkF6WpXwCCgkF?p=preview
I was able to accomplish the desired affect by inserting a second search box within the 'navbar-header' section, but that caused by typeahead code to go crazy.
Code
Here's the header section of my HTML:
<header>
<div class="navbar navbar-default navbar-static-top" role="navigation">
<div class="container">
<div class="navbar-header">
<button class="navbar-toggle collapsed" data-target=".navbar-collapse" data-toggle="collapse" type="button">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="hidden-xs">
<a class="navbar-brand" href="/">Some Project</a>
</div>
<div class="visible-xs">
<a class="navbar-brand" href="/">P</a>
</div>
</div>
<div class="navigation">
<div class="pull-right" id="navbar-search-area">
<form class="navbar-form site-search" id="new_search" action="/search" accept-charset="UTF-8" method="get"><input name="utf8" type="hidden" value="✓">
<div class="form-group">
<div class="icon-addon addon-sm">
<input id="search" placeholder="search" input-html="col-xs-5 col-sm-3 col-md-4" type="text" name="search[term]" />
<label class="glyphicon glyphicon-search" rel="tooltip" title="search"></label>
</div>
</div>
</form>
</div>
<div class="collapse navbar-collapse header-collapse" id="navbar-section-1">
<ul class="nav navbar-nav">
<li>
Pick Me!
</li>
<li>
me me me me!
</li>
</ul>
</div>
</div>
</div>
</div>
</header>
Any guidance would be appreciated.
References
Other people have had similar questions but they all seem a little different, in large part because there isn't a super-standard way to do this, and because people want their web pages to behave in different ways.
Aligning search bar for mobile with bootstrap 3
[update] updated css in plunkr to show that the nav bar stretches across the top in a different background color.

Pulling the search and collapsed navbar out of the header and right aligning them seems to do the trick
http://plnkr.co/edit/B4gIfAkNiwkBId9fbLVi?p=preview
<!DOCTYPE html>
<html ng-app="plunker">
<head>
<title>AngularJS Plunker</title>
<!-- your app.js file -->
<script src="app.js"></script>
<!-- bootstrap css -->
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" />
<!-- your style.css file -->
<link href="style.css" rel="stylesheet" />
</head>
<body class="pages welcome">
<style>
body { background-color: #F9F7F5; }
</style>
<header>
<div class="navbar navbar-default navbar-static-top" role="navigation">
<button class="pull-right navbar-toggle collapsed" data-target=".navbar-collapse" data-toggle="collapse" type="button">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<div class="pull-right" id="navbar-search-area">
<form class="navbar-form site-search" id="new_search" action="/search" accept-charset="UTF-8" method="get"><input name="utf8" type="hidden" value="✓">
<div class="form-group">
<div class="icon-addon addon-sm">
<input id="search" placeholder="search" input-html="col-xs-5 col-sm-3 col-md-4" type="text" name="search[term]" />
<label class="glyphicon glyphicon-search" rel="tooltip" title="search"></label>
</div>
</div>
</form>
</div>
<div class="container">
<div class="navbar-header">
<div class="hidden-xs">
<a class="navbar-brand" href="/">Some Project</a>
</div>
<div class="visible-xs">
<a class="navbar-brand" href="/">P</a>
</div>
</div>
<div class="navigation">
<div class="collapse navbar-collapse header-collapse" id="navbar-section-1">
<ul class="nav navbar-nav">
<li>
Pick Me!
</li>
<li>
me me me me!
</li>
</ul>
</div>
</div>
</div>
</div>
</header>
<div class="container">
<div class="row">
<div class="col-md-8 col-md-push-2">
<h1 class="page-title">Welcome to the Project</h1>
<p>This is the body.</p>
</div>
</div>
</div>
</body>
</html>

Related

Hamburger menu appearing in the centre of the mobile screen of BS5

I'm using BS5 and got this working for desktop screen sizes but when it comes to mobile screens, everything goes for a toss!
What I want on mobile screen by keeping the Desktop view as-is:
The search button to be shown next to the hamburger menu instead of showing inside in the dropdown when hamburger menu is clicked.
The hamburger menu is to be shown next to the Search button instead of in the middle.
When I change the DIV positions, more problems come out.
JSFiddle Demo
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.2/dist/css/bootstrap.min.css" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">
<header class="menu">
<nav class="navbar navbar-expand-sm">
<div class="container">
<a class="navbar-brand" href="/">
Logo
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div id="navbarCollapse" class="collapse navbar-collapse">
<ul id="menu-main-menu-1" class="navbar-nav">
<li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-7">Sample Page</li>
<li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-8">Uncategorized</li>
</ul>
</div>
<div class="search">
<a data-bs-toggle="offcanvas" href="#demo">SEARCH</a>
</div>
</div>
</nav>
<div class="offcanvas offcanvas-top" id="demo">
<div class="container">
<div class="row">
<div class="col-lg-11 col-11">
<section id="block-9" class="widget_block">
<div class="wp-container-1 wp-block-group">
<div class="wp-block-group__inner-container">
<form role="search" method="get" action="/" class="wp-block-search__no-button alignleft wp-block-search"><label for="wp-block-search__input-1" class="wp-block-search__label screen-reader-text">Search</label>
<div class="wp-block-search__inside-wrapper"><input type="search" id="wp-block-search__input-1" class="wp-block-search__input " name="s" value="" placeholder="Search..." required=""></div>
</form>
</div>
</div>
</section>
</div>
<div class="col-lg-1 col-1">
<button type="button" class="float-end btn-close mt-2" data-bs-dismiss="offcanvas"></button>
</div>
</div>
</div>
</div>
</header>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>

Bootstrap - Navbar and footer with same structure

I'm new to Bootstrap and I want to have my navbar and footer with the same structure, it means colors and font family mainly, I've took code from Bootstrap themes for each of and from different sources, I've done the navbar part and I now want the footer to be with same structure but I don't understand how to do it.
Navbar part:
<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="#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-left" href="#"><img src="images/_ressources/logo.svg" height="50px"></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> ACCUEIL </li>
<li> BOUTIQUE </li>
<li> CONTACT </li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li> MON COMPTE </li>
<li>
<div class="input-group-btn">
<button type="button" class="btn btn-default btn-lg" style="background-color:orange"> <span class="glyphicon glyphicon-lock" ></span> </button>
</div>
</li>
</ul>
<form class="navbar-form navbar-right" role="search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Recherche un produit">
<div class="input-group-btn">
<button class="btn btn-default" type="submit"><i class="glyphicon glyphicon-search"></i></button>
</div>
</div>
</form>
<!-- /.navbar-collapse -->
</div>
</div>
<!-- /.container -->
</nav>
Footer part:
<footer id="footer">
<div class="container">
<div class="row">
<div class="col-xs-6 col-sm-6 col-md-3 column">
<h4>Information</h4>
<ul class="nav">
<li>Products</li>
<li>Services</li>
<li>Benefits</li>
<li>Developers</li>
</ul>
</div>
</div>
</div>
</footer>
Here's what I want to have :
Thanks for the help !
You could use your own stylesheet, which overrides the bootstrap one. Just put this in the head section
<head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/custom.css">
</head>
To modify or apply additional styling to your web page, simply add the proper code to your custom.css file. There is no need to edit any of the original Bootstrap styles directly.
For example, if you decided that you did not like the rounded corners on the buttons, you could apply the following style in your custom.css file.
.btn {
border-radius: 0px;
}
Now if you add a button to your web page with the default Bootstrap styles (.btn class), the corners aren’t rounded. This is due to the fact that your custom stylesheet overrides the default Bootstrap stylesheet.
source: https://bootstrapbay.com/blog/customize-bootstrap/

Why am I getting too much pixels for padding using Twitter Bootstrap?

I have made a header prototype using bootstrap. The problem is I couldn't understand why I have such big padding for the right side. If I add one more letter after Корзина HTML gives me a new line. How could I get rid of this free space? Here is the image
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<body>
<!-- Navigation -->
<!-- Heading beginning -->
<div class="container">
<div class="jumbotron">
<div class="row">
<div class="col-md-2"><img src="http://placehold.it/75x75" id="nttLogo"></div>
<div class="col-md-8">
<input type="text" name="searchPattern" placeholder="Введите название лекарства, или препарата" id="searchForm">
<button type="button">Search</button>
<span class="glyphicon glyphicon-heart-empty"><p id="websiteSlogan">Отложенное </p></span>
<span class="glyphicon glyphicon-folder-open"><p id="websiteSlogan">Корзина</p></span>
</div>
<div class="col-md-8">
<small>Например, лекарства для диабетиков</small>
</div>
</div>
<nav class="navbar navbar-inverse" 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="#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="#">Start Bootstrap</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>
About
</li>
<li>
Services
</li>
<li>
Contact
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
</div>
</div>
<!-- Heading end-->
</body>
You need to increase the col-md-8 to col-md-10 and float the elements to right to remove empty space from right.
here is the updated demo

Bootstrap search field with icon in navigation header not appearing correctly

I'm attempting to add a search box with a header to my Bootstrap 3 template. The template that I'm using was purchased from the Bootstrap themes page and is the Light UI Dashboard theme.
I found this answer on Stack Overflow but it's not appearing correctly (it appears incorrectly in both Chrome and Edge).
How to add a search box with icon to the navbar in Bootstrap 3?
I modified my code to include the search box in my header however the glyphicon doesn't display and the search box is out of alignment. Here is a screen shot.
My code is as follows:
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css');
<form runat="server">
<!-- Fixed navbar -->
<nav class="navbar navbar-inverse navbar-fixed-top">
<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">
<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="/">Crown Ent.</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-left">
<li role="presentation" id="dashboard">Dashboard</li>
<li role="presentation" id="workorders">Work Orders</li>
<li role="presentation" id="invoices">Invoices</li>
<li role="presentation" id="accounts">Accounts</li>
<li role="presentation" id="people">People</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a runat="server" href="~/admin">Settings</a></li>
<li><a runat="server" href="~/admin">Help</a></li>
</ul>
<form class="navbar-form" style="padding-top:5px;">
<div class="form-group" style="display:inline;margin-top:5px;">
<div class="input-group" style="display:table;">
<span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span>
<input class="form-control" name="search" placeholder="Search Here" id="crown-search" autocomplete="off" autofocus="autofocus" type="text">
</div>
</div>
</form>
</div>
</div>
</nav>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
I can't see anything wrong with the code. Adjusting the CSS margin in an attempt to fix the positioning is also ineffective.
UPD. I removed the first line <form runat="server"> and used the code
<form class="navbar-form" role="search">
<div class="form-group">
<div class="input-group">
instead of
<form class="navbar-form" style="padding-top:5px;">
<div class="form-group" style="display:inline;margin-top:5px;">
<div class="input-group" style="display:table;">
And I've added some CSS to make the form wider. Please check the result.
#import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css');
#navbar .navbar-form {
overflow: hidden;
}
#navbar .form-group,
#navbar .input-group {
width: 100%;
}
#navbar .input-group-addon {
width: 39px;
}
<!-- Fixed navbar -->
<nav class="navbar navbar-inverse navbar-fixed-top">
<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">
<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="/">Crown Ent.</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-left">
<li role="presentation" id="dashboard">Dashboard</li>
<li role="presentation" id="workorders">Work Orders</li>
<li role="presentation" id="invoices">Invoices</li>
<li role="presentation" id="accounts">Accounts</li>
<li role="presentation" id="people">People</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a runat="server" href="~/admin">Settings</a></li>
<li><a runat="server" href="~/admin">Help</a></li>
</ul>
<form class="navbar-form" role="search">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span>
<input class="form-control" name="search" placeholder="Search Here" id="crown-search" autocomplete="off" autofocus="autofocus" type="text">
</div>
</div>
</form>
</div>
</div>
</nav>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
All you have to do is add the span that holds the search icon after the input field if you want it to be on the other side
So
<div class="input-group" style="display:table;">
<input class="form-control" name="search" placeholder="Search Here" id="crown-search" autocomplete="off" autofocus="autofocus" type="text">
<span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span>
</div>
Also just looks like you need to apply a margin-top value to the input-group class feel free to add another class called search or something to apply it too as well
This seems like a simple css fix
FYI the glyph icon appears in all 3 of my browsers (Chrome, FF, and IE)
in order to fix out of alignment problem change this:
<div class="form-group" style="display:inline;margin-top:5px;">
to this:
<div style="margin-top:5px;">

Vertical alignment of navbar in tablet-landscape resolutions - link not aligned

There's one link that stays up on the top line, next to "search jobs by," in certin screen resolutions of the collapsed navbar. Also, within these same resolutions, the client login continues to work like the "desktop/laptop" client login instead of the mobile login. I'm having this problem with various tablet resolutions only (when width is between 768px and 1023px).
The "State" link, between widths 768px and 1023px, is still on the same line as the "Search jobs by:" text in the collapse navbar, as per the photo I uploaded. Also, the client login dropdown is operating like the expanded navbar version instead of the collapsed navbar version within the 768px and 1023px width range. The picture above shows this weird appearance.
See visual below:
http://www.bootply.com/Cl8RGWpCqv
What's the best way to fix this in bootstrap 3 (Note: I'm using regular css/css3, neither less nor sass)?
<nav class="navbar navbar-default navbar-static-top" 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="#tusaj-main">
<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 brandmedia" href="#"><img src="img/logo_final.png" alt=""></a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="pspacerv20t spacerh10r">
<div class="collapse navbar-collapse" id="tusaj-main">
<ul class="nav navbar-nav navbar-right">
<p class="navbar-text">Search Jobs By:</p>
<li>State</li>
<li class="divider-vertical"></li>
<li><div class="spacerh80"> Category</div></li>
<li>Post Jobs</li>
<li class="divider-vertical"></li>
<li class="dropdown">
Client Login <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li>
<form class="form-inline no-margin center-block" role="form">
<div class="form-group pspacerv10b pspacerv10t">
<div class="col-sm-5">
<input type="text" placeholder="Username" class="form-control">
</div>
</div>
<div class="form-group pspacerv10b">
<div class="col-sm-5">
<input type="password" placeholder="Password" class="form-control">
</div>
</div>
<!--<div class="form-group pspacerv10b">
<div class="col-sm-6">
<div class="checkbox">
<label><input type="checkbox"> Remember me</label>
</div>
</div>
</div> /-->
<div class="form-group center-block pspacerv10b">
<div class="col-sm-3">
<button type="submit" class="btn btn-success">Sign in</button>
</div>
</div>
</form>
</li>
</ul>
</li>
</ul>
</div>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
<div class="tagline col-lg-12">
<p class="taglinealignright pspacerv15t spacerh25r">Search Jobs and Careers: Find Your Ideal Job. 1,000s of New Jobs Daily!</p>
<br />
</div>
</nav>
Demo