Aligning searchbar to the right in bootstrap 5 - html

Is it possible to have the searchbar in the bootstrap navbar to be fixed to the right side of the screen or would that go against it's flexibility? I'd like it to stay at the rightmost side of the screen regardless of the amount of links in my navbar. I'm a beginner to both css and bootstrap so I was unsure if I should edit the size in the class section of the element or override it in css. I've managed to modify other aspects of the navbar but I can't seem to move the search bar one bit. I assume it's since d-flex makes it next to the previous element.
#navbarDog{
background-color: #F5EFE6;
}
#logo{
height: 100px;
}
.nav-link{
font-size: 20px;
transition: font-size 0.4s;
}
.nav-link:hover{
font-size: 25px;
}
.header-products {
display: flex;
align-items: center;
justify-content: center;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Flexbox excersice - Fibonacci Flexbox</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.1/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-iYQeCzEYFbKjA/T2uDLTpkwGzCiq6soy8tYaI1GyVh/UjpbCx/TYkiZhlZB6+fzT" crossorigin="anonymous">
<link rel="stylesheet" href="css/style.css">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0/dist/js/bootstrap.min.js"
integrity="sha384-ODmDIVzN+pFdexxHEHFBQH3/9/vQ9uori45z4JjnFsRydbmQbmL5t1tQ0culUzyK"
crossorigin="anonymous"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg" id="navbarDog">
<div class="container-fluid">
<a class="navbar-brand" href="index.html" ><img src="../img/logo.png" alt="" id="logo"></a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false"
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="index.html">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="products.html">Products</a>
</li>
<li class="nav-item">
<a class="nav-link" href="news.html">News</a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.html">About</a>
</li>
<form class="d-flex">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</div>
</nav>
<header class="header-products">
<h1>Products</h1>
</header>
<main>
<div class="gallery">
<img src="" alt="">
</div>
<p>Feel free to purchase one of our t-shirts, your money will go to save even more dogs</p>
</main>
</body>

The problem is with the width of your navbar, just replace me-auto with w-100 and give the search bar ms-auto to push it to the right.
<ul class="navbar-nav w-100 mb-2 mb-lg-0">
.
.
.
<form class="d-flex ms-auto">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>

Related

How to center search icon in bootstrap navbar

I have problem in 2 things:
How do I Make the search bar in left on desktop side as shown here and how to avoid This
On small devices?
When the display is small, it shows a button to display the list, but when I click the button, nothing happens
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.3.1/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div class="App">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse">
<a class="navbar-brand" href="#">Brand Name</a>
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
<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="#">Products</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-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>
</nav>
</div>
What I tried:
1: I tried using css text-align: left and it doesen't work
You could use some css to add flex-grow and a max-width
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>AA</title>
</head>
<body>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap#4.3.1/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<div class="App">
<nav class="navbar navbar-expand-lg navbar-light bg-light" style="flex-wrap: nowrap;">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse">
<a class="navbar-brand" href="#">Brand Name</a>
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
<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="#">Products</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
<form class="form-inline my-2 my-lg-0" style="flex-grow: 1; max-width: 300px; width: auto; flex-wrap: nowrap;">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search" style="flex-grow: 1;">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</nav>
</div>
</body>
</html>

Why my bootstrap toggler is not showing items?

Im using bootstrap version5 and learning about navbar togglers but my togler is not showing any content on clicking.
Here is my code.
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
<a class="navbar-brand" href="#">Hidden brand</a>
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
<form class="d-flex">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</div>
</nav>
In learning bootstrap and creating a navbar using nav, So I used navbar toggler for small devices so I kept all my links in a toggler button but while clicking on toggler button nothing is showing
And this what I get.
The HTML markup you have shared with your post is correct. It should show the navigation panel while clicking on the toggle button.
I think you have not included the Bootstrap JavaScript file properly with your page. That is why the panel is not responding while clicking on the button.
Add the bootstrap JavaScript file to your page and it will work properly as you expected.
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/js/bootstrap.bundle.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
<a class="navbar-brand" href="#">Hidden brand</a>
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
<form class="d-flex">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</div>
</nav>
Change data-bs- to data- in your toggle button.
Tested on jsfiddle: https://jsfiddle.net/r3ktuL5f/
Your code is quite good but You missed to hook up bootstrap5 correctly ;-)
As we can read in official docs:
Include Bootstrap’s CSS and JS. Place the tag in the for
our CSS, and the tag for our JavaScript bundle (including
Popper for positioning dropdowns, poppers, and tooltips) before the
closing </body>.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap demo</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
</head>
<body>
<h1>Hello, world!</h1>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
</body>
</html>
You can also include Popper and our JS separately. If you don’t plan
to use dropdowns, popovers, or tooltips, save some kilobytes by not
including Popper.
<script src="https://cdn.jsdelivr.net/npm/#popperjs/core#2.11.5/dist/umd/popper.min.js" integrity="sha384-Xe+8cL9oJa6tN/veChSP7q+mnSPaj5Bcu9mPX5F5xIGE0DVittaqT5lorf0EI7Vk" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/js/bootstrap.min.js" integrity="sha384-kjU+l4N0Yf4ZOJErLsIcvOU2qSb74wXpOhqTvwVx3OElZRweTnQ6d31fXEoRD1Jy" crossorigin="anonymous"></script>
Your code example which is works fine when it is hook up correctly...:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bootstrap demo</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<div class="container-fluid">
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarTogglerDemo01" aria-controls="navbarTogglerDemo01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarTogglerDemo01">
<a class="navbar-brand" href="#">Hidden brand</a>
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true">Disabled</a>
</li>
</ul>
<form class="d-flex">
<input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success" type="submit">Search</button>
</form>
</div>
</div>
</nav>
<h1>Hello, world!</h1>
<h3 class="fs-2 text-danger">If You want to use bootstrap5 You need to hook up bootstrap5 correctly ;-)</h3>
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.0-beta1/dist/js/bootstrap.bundle.min.js" integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2" crossorigin="anonymous"></script>
</body>
</html>
Did you include the Bootstrap js file ? If not, the nav bar won't work properly.

Bootstrap Responsive Menu button won't Respond

I'm having a bad time with this Bootstrap menu I made, and I can't figure it out why it won't collapse, animate. Everything works great and all, but the button doesn't work.
<nav class="navbar navbar-expand-lg navbar-light bg-dark alb">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<!-- Logo pentru desktop -->
<a href="index.html" class="logo">
<img src="img/logo.png" alt="IMG-LOGO">
</a>
<div class="collapse navbar-collapse" id="navbarTogglerDemo03">
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
<li class="nav-item active">
<a class="nav-link" href="#" style="color:white">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" style="color:white">Marci moto</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true" style="color:white">Sectiune dezactivata</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit" style="color:white">Cautare</button>
</form>
</div>
</nav>
I have used your same code and just use online CDN in my code it's works fine for the same code you are provided. Compare your code with mine and find what was the mistake.
following is the snippet of my code:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-dark alb">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a href="index.html" class="logo">
<img src="img/logo.png" alt="IMG-LOGO">
</a>
<div class="collapse navbar-collapse" id="navbarTogglerDemo03">
<ul class="navbar-nav mr-auto mt-2 mt-lg-0">
<li class="nav-item active">
<a class="nav-link" href="#" style="color:white">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#" style="color:white">Marci moto</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true" style="color:white">Sectiune dezactivata</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit" style="color:white">Cautare</button>
</form>
</div>
</nav>
</body>
</html>
I hope this will help you to solve your problem.
Thank You...

Make the navigation links below in the login form

Im trying to create a navigation which has a login form and below login form is the menu links.
I want these two in my navigation. But the problem is that the output has only given me is one horizontal. And the menu links are not below in the login form.
I want the menu links below the login form. But it's giving me a wrong output
CSS:
.nav-link {
font-size: 18px !important;
text-transform: uppercase !important;
font-weight: 600 !important;
}
.navbar-light .navbar-nav .nav-link {
color: #ffff !important;
}
#search { margin: auto; }
body {
overflow-x: hidden;
}
HTML:
<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0,
maximum-scale=1, user-scalable=no">
<title></title>
<!-- favicon -->
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="theme-color" content="#ffffff">
<!-- /favicon -->
<link href="/realcss/bootstrap-4.1.3.min.css" type="text/css" rel="stylesheet">
<link href="/realcss/flag-icon.min.css" type="text/css" rel="stylesheet">
<link href="/realcss/fontawesome-all-5.3.min.css" type="text/css" rel="stylesheet">
<link href="/css/layout.css" type="text/css" rel="stylesheet">
</head>
<body>
<!-- navigation.tpl -->
<header>
<nav class="navbar navbar-expand-md navbar-light fixed-top bg-dark border-bottom" style="float: right;">
<a class="navbar-brand" href="#"><img class="logo" src="/images/logo/M.png" style="max-width: 400px;
max-height: 64px;" alt=""></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse justify-content-center" id="navbarCollapse">
<div id="search">
<form class="d-flex justify-content-center align-items-center form-inline my-2 my-lg-0">
<div class="col-auto pl-0">
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text"><i class="fa fa-user"></i></div>
</div>
<input type="email" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Email Address">
</div>
</div>
<div class="col-auto pl-0">
<div class="input-group">
<div class="input-group-prepend">
<div class="input-group-text"><i class="fa fa-lock"></i></div>
</div>
<input type="password" class="form-control" id="inlineFormInputGroup" placeholder="Password">
</div>
</div>
<div class="col-auto pl-0 pr-0">
<button class="btn btn-primary my-2 my-sm-0" type="submit">Login</button>
</div>
</form>
</div>
<ul class="navbar-nav d-flex justify-content-center">
<li id="li-home" class="nav-item active">
<a id="link-home" class="nav-link" href="#">Home<span class="sr-only">(current)</span></a>
</li>
<li id="li-about" class="nav-item">
<a id="link-about" class="nav-link" href="#">Link</a>
</li>
<li id="li-team" class="nav-item">
<a id="link-team" class="nav-link" href="#">Link</a>
</li>
<li id="li-news" class="nav-item">
<a id="link-news" class="nav-link" href="#">Link</a>
</li>
<li id="li-contact" class="nav-item">
<a id="link-contact" class="nav-link" href="{{ route('promotion') }}">Promotion</a>
</li>
</ul>
</div>
</nav>
</header>
</body>
Try the following CSS:
.navbar-expand-md .navbar-collapse{
flex-direction:column;
}
Live Demo

Bootstrap 4 - Navbar searchbar center

I'm currently struggling a bit on centring my search bar inside my nav. I've tried many different things, like mr-atuo and ml-auto or mx-auto but I just can't get the element to move. I don't want to use individual pixels because then it will look horrible on mobile. Here is a small demonstration of where the bar needs to be and where it currently is: https://imgur.com/a/bHXJD
Here is the code for my navbar:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!DOCTYPE html>
<html lang="nl">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="https://use.fontawesome.com/0ba2bca7b4.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light navbar-custom z-depth-half">
<div class="container">
<a class="navbar-brand" href="#">
<i class="fa fa-skype"></i>
</a>
<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" id="navbarSupportedContent">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
Vragen
</li>
<li class="nav-item">
Aanbieders
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item" style="border-right: 0.1rem solid lightgrey">
<form class="form-inline">
<input class="form-control mr-sm-2 search-input" type="search" placeholder="Zoeken..." name="search" id="search">
<button class="btn btn-search my-2 my-sm-0 " type="submit">
<i class="fa fa-search"></i>
</button>
</form>
</li>
<li class="nav-item">
<a class="nav-link" href="">Aanmelden</a>
</li>
<li class="nav-item">
<a class="nav-link btn nav-register-btn" href="">Registreren</a>
</li>
</ul>
</div>
</div>
</nav>
</body>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
</html>
Thanks in advance!
You will have to change your HTML structure a bit. Move the form out of the UL
HTML:
...
</ul>
<form class="form-inline">
<input class="form-control mr-sm-2 search-input" type="search" placeholder="Zoeken..." name="search" id="search">
<button class="btn btn-search my-2 my-sm-0 " type="submit">
<i class="fa fa-search"></i>
</button>
</form>
<ul class="navbar-nav">
...
CSS:
.form-inline{
width: 100%;
display: flex;
justify-content: center;
}
.form-inline #search{
width: 50%;
}
JsFiddle
One solution would be to assign a min-width to your .form-inline and let the .search-input grow with flex-box:
.form-inline {
min-width: 500px;
}
.search-input {
flex-grow: 3;
}
codepen