bootstrap 3 - how do I place the brand in the center of the navbar?

后端 未结 8 1492
臣服心动
臣服心动 2020-11-30 04:27

I am using Bootstrap 3. I would like a navbar with only the brand in it. No other links or anything else. And I want the brand to be in the center. How can I accomplish t

相关标签:
8条回答
  • 2020-11-30 04:39

    In bootstrap, simply use mx-auto class along with navbar-brand.

    0 讨论(0)
  • 2020-11-30 04:43

    Just create this class and add it to your element to be centered.

    .navbar-center {
      margin-left: auto;
      margin-right: auto;
    }
    
    0 讨论(0)
  • 2020-11-30 04:46

    Use these classes: navbar-brand mx-auto

    All other solutions overcomplicate the matter.

    0 讨论(0)
  • 2020-11-30 04:47

    To fix the overlap, you only need modify the .navbar-toggle in your own css styles

    something like this, it works for me:

    .navbar-toggle{
    z-index: 10;
    }
    
    0 讨论(0)
  • 2020-11-30 04:48

    If you have no other links, then there is no use for navbar-header....

    HTML:

    <nav class="navbar navbar-inverse navbar-static-top">
        <div class="container">
         <a class="navbar-brand text-center center-block" href="#">Navbar Brand</a>
      .....
    </nav>
    

    CSS:

    .navbar-brand {
      float: none;
    }
    


    However, if you do want other links here's a very effective approach that allows that: https://stackoverflow.com/a/34149840/3123861

    0 讨论(0)
  • 2020-11-30 04:52

    css:

    .navbar-header {
        float: left;
        padding: 15px;
        text-align: center;
        width: 100%;
    }
    .navbar-brand {float:none;}
    

    html:

    <nav class="navbar navbar-default" role="navigation">
      <div class="navbar-header">
        <a class="navbar-brand" href="#">Brand</a>
      </div>
    </nav>
    
    0 讨论(0)
提交回复
热议问题