I'm finding it difficult to center my search bar inside my navigation. I've experimented with different options like mr-auto
and ml-auto
or mx-auto
, but the element just won't budge. I want to avoid using specific pixel values as it may affect the responsiveness on mobile devices. Here is a simple visualization of where the search bar should be and where it currently is located: https://i.sstatic.net/qDE7d.jpg
Here is the code snippet for my navigation bar:
<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">
<a href="#" class="nav-link">Questions</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link">Providers</a>
</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="Search..." 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="">Sign In</a>
</li>
<li class="nav-item">
<a class="nav-link btn nav-register-btn" href="">Register</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>
Appreciate any help in advance!