Move down button and center - Bootstrap 4

Asked

Viewed 1,930 times

-1

I’m trying to create a layout with bootstrap 4 and for that I took an example of navbar on their website. The problem is that I would like to lower the mobile button on a new line and centralize, however, I am not succeeding, I have already used the classes .text-center, .mx-auto I’ve tried to give a display: block; but it just won’t.

These days it’s like this:

inserir a descrição da imagem aqui

I want you to stay like this:

inserir a descrição da imagem aqui

Code:

<nav class="navbar navbar-toggleable-md navbar-inverse bg-inverse d-flex align-items-center">
            <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navSuperior" aria-controls="navSuperior" aria-expanded="false">
                <span class="navbar-toggler-icon"></span>
            </button>
            <a class="navbar-brand" href="#"><div id="navLogo">LOGO</div></a>
            <div class="collapse navbar-collapse" id="navSuperior">
                <div id="navSearch">
                    <form class="form-inline d-flex p-2">
                        <input class="form-control" type="text" placeholder="Search">
                        <button class="btn btn-outline-success" type="submit">Search</button>
                    </form>
                </div>
                <div id="navMenu">
                    <ul class="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="#">Link</a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link disabled" href="#">Disabled</a>
                        </li>
                    </ul>  
                </div>
            </div>
        </nav>
  • Young man, the snippet you provided isn’t even close to the image. You tested your own example ?

1 answer

1


Testing in the mentioned example of the Bootstrap site, add the Styles:

In the <a> of LOGO:

style="display: block; width: 100%; text-align: center; margin: 0;"

In the <button>:

style="margin: 0 auto;"

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"></script>
<nav class="navbar navbar-dark bg-dark">
      <a style="display: block; width: 100%; text-align: center; margin: 0;" class="navbar-brand" href="#">LOGO</a>
      <button style="margin: 0 auto;" class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarsExample01" aria-controls="navbarsExample01" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>

      <div class="collapse navbar-collapse" id="navbarsExample01">
        <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="#">Link</a>
          </li>
          <li class="nav-item">
            <a class="nav-link disabled" href="#">Disabled</a>
          </li>
          <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="http://example.com" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</a>
            <div class="dropdown-menu" aria-labelledby="dropdown01">
              <a class="dropdown-item" href="#">Action</a>
              <a class="dropdown-item" href="#">Another action</a>
              <a class="dropdown-item" href="#">Something else here</a>
            </div>
          </li>
        </ul>
        <form class="form-inline my-2 my-md-0">
          <input class="form-control" type="text" placeholder="Search" aria-label="Search">
        </form>
      </div>
    </nav>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.