我如何得到glyphicon在引导导航栏的中心?(how do i get glyphicon in

2019-10-20 23:01发布

我试图让glyphicon日志 - 在导航栏引导的中心,甚至没有进入导航栏的意思是它显示导航栏上面,调试时。

<a class="navbar-brand pull-left" href="/"><img src="images/logo.png" alt="Elunika"></a>

<span class="glyphicon glyphicon-log-in" id="logIcon"></span>

<div class="nav-collapse collapse navbar-responsive-collapse">
        <ul class="nav navbar-nav pull-right">
                <li class="active">
                    <a href="#">HOME</a>
                </li>
                <li>
                    <a href="#">ABOUT</a>
                </li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown"> WHO, HOW & WHAT? </a>

                <ul class="dropdown-menu">
                    <li>
                        <a href="#">WHO WE ARE?</a>
                    </li>

                    <li>
                        <a href="#">WHAT IS IT?</a>
                    </li>

                    <li>
                        <a href="#">HOW IT WORKS?</a>
                    </li>

                </ul>
                    </li>
                <li>
                    <a href="#">CONTACT US</a>
                </li>
        </ul>
  </div>

和CSS logIcon是如下

#logIcon{
position: absolute;
margin-left:auto;
margin-right:auto;
}

谢谢你提前任何帮助

Answer 1:

从你的链接bootsnipp,你只需要与你的glyphicon跨度一词取代“品牌”。

<div class="navbar-brand navbar-brand-centered"><span class="glyphicon glyphicon-log-in" id="logIcon"></span></div>

下面是工作提琴代码: http://www.bootply.com/EmzUMHPXqd



Answer 2:

http://www.bootply.com/eHiWDODA83

你可以创建一个新的类像这样的图标..

.navbar-center
{
    position: absolute;
    width: 100%;
    top: 0;
    text-align: center;
    margin-left: auto;
    margin-right: auto;
}

然后用类似这样的标记..

<nav class="navbar" role="navigation">
  <div class="navbar-header">
    <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
      <span class="icon-bar"></span>
    </button>    
  </div>
  <a class="navbar-center navbar-text" href="#"><span class="glyphicon glyphicon-log-in" id="logIcon"></span></a>
  <div class="navbar-collapse collapse">
    <a class="navbar-brand" href="/"><img src="images/logo.png" alt="Elunika"></a>

    <ul class="nav navbar-nav navbar-right">
      <li class="active">
        <a href="#">HOME</a>
      </li>
      <li>
        <a href="#">ABOUT</a>
      </li>
      <li class="dropdown">
        <a href="#" class="dropdown-toggle" data-toggle="dropdown"> WHO, HOW &amp; WHAT? </a>

        <ul class="dropdown-menu">
          <li>
            <a href="#">WHO WE ARE?</a>
          </li>

          <li>
            <a href="#">WHAT IS IT?</a>
          </li>

          <li>
            <a href="#">HOW IT WORKS?</a>
          </li>

        </ul>
      </li>
      <li>
        <a href="#">CONTACT US</a>
      </li>
    </ul>
  </div>
</nav>

http://www.bootply.com/eHiWDODA83



文章来源: how do i get glyphicon in the center of the bootstrap navbar?