title: Bootstrap 4 Navbar search box not aligning in center
body: <p>I've gone through almost every question regarding center aligning elements in a navbar, haven't found an answer yet.</p>
  
  <p>I've been trying to center align a search bar inside of my navbar but outside of the collapsible button. The problem is, no matter what I do, I can't get the search box in the center. It just stays to the left.</p>
  
  <p>However, if I make the viewport smaller, as soon as the links on the right disappear inside the collapsible button, the search box aligns just fine in the center. Here's my Navbar code:</p>
  
  <pre><code>&lt;header&gt;
    &lt;nav class="navbar navbar-expand-md navbar-dark fixed-top bg-dark"&gt;
      &lt;a class="navbar-brand" href="#"&gt;Carousel&lt;/a&gt;
      &lt;form class="form-inline justify-content-center" style="text-align: center;"&gt;
        &lt;input class="form-control mr-sm-2"type="text" placeholder="Search" aria-label="Search"&gt;
        &lt;button class="btn btn-outline-success my-2 my-sm-0" type="submit"&gt;Search&lt;/button&gt;
      &lt;/form&gt;
      &lt;button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation"&gt;
        &lt;span class="navbar-toggler-icon"&gt;&lt;/span&gt;
      &lt;/button&gt;
      &lt;div class="collapse navbar-collapse" id="navbarCollapse"&gt;
        &lt;ul class="navbar-nav ml-auto "&gt;
          &lt;li class="nav-item active"&gt;
            &lt;a class="nav-link" href="#"&gt;Home &lt;span class="sr-only"&gt;(current)&lt;/span&gt;&lt;/a&gt;
          &lt;/li&gt;
          &lt;li class="nav-item"&gt;
            &lt;a class="nav-link" href="#"&gt;Log in&lt;/a&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/div&gt;
    &lt;/nav&gt;
  &lt;/header&gt;
  </code></pre>
  
  <p>I want the search box to be outside of the collapsible button but aligned in the center. I've tried adding <code>mx-auto</code> along with width but it doesn't work. I've tried dozens of other questions on SO, nothing's worked out yet. </p>
  
  <p>I'm attaching screenshots for your reference
  <a href="https://i.stack.imgur.com/UPI4J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UPI4J.png" alt="That&#39;s how the navbar looks in full viewport width"></a>
  When in full width, the search bar doesn't center align</p>
  
  <p><a href="https://i.stack.imgur.com/VOoNR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VOoNR.png" alt="enter image description here"></a>
  As soon as the collapsible button appears everything works just fine.</p>
  
  <p>How do I get the search box aligned in the center?<br>
  Also, is there any way to increase the width of the search box without using explicit CSS styling, as that breaks the responsive behavior? </p>