Bootstrap - 对齐导航栏的品牌徽标和选项菜单(图标+文本)

时间:2016-10-02 10:08:55

标签: css twitter-bootstrap

我无法将品牌徽标以及文本和图像图标与导航栏对齐以使用引导环境。

问题是徽标位于导航栏的外部,图标与文本不对齐。

请你能帮帮我吗?

Te代码是这样的:

<!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <title>Web Testing</title>

        <!-- INCLUDES -->

        <link rel="stylesheet" href="assets/bootstrap/css/bootstrap.css">
        <link rel="stylesheet" href="assets/bootstrap-table/dist/bootstrap-table.css">
        <link rel="stylesheet" href="assets/bootstrap-editable/css/bootstrap-editable.css">

        <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

        <script src="assets/jquery/jquery.min.js"></script>
        <script src="assets/bootstrap/js/bootstrap.min.js"></script>
        <script src="assets/bootstrap-table/dist/bootstrap-table.js"></script>
        <script src="assets/bootstrap-editable/js/bootstrap-editable.js"></script>

    </head>

    <body>          
            <!-- NAVIGATION -->

            <nav class="navbar navbar-default">
              <div class="container-fluid"> 
                <div class="navbar-header">
                  <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#defaultNavbar1"><span class="sr-only">Toggle navigation</span><span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span></button>
                  <a class="navbar-brand" href="http://www.google.es"><img src="assets/images/brandlogo.png"/></a></div>
                <div class="collapse navbar-collapse" id="defaultNavbar1">
                  <ul class="nav navbar-nav">
                    <li class="active marges-opciones-right" ><a href="produccio.php"><i class="material-icons" style="font-size: 40px">work</i> Page1<span class="sr-only">(current)</span></a></li>
                    <li class="text-options marges-opciones-right"><a href="imatges.php"><i class="material-icons" style="font-size: 40px">collections</i> Page2</a></li>
                  </ul>
                  <ul class="nav navbar-nav navbar-right">
                    <li class="dropdown marges-opciones-left"><a href="#" class="dropdown-toggle" 
                    data-toggle="dropdown" role="button" aria-expanded="false"><i class="material-icons" style="font-size: 40px" >face</i><span class="username"> Username </span><i class="material-icons" style="font-size: 40px" >list</i></a>
                      <ul class="dropdown-menu" role="menu">
                        <li><a href="underconstruction.html"><span class="glyphicon"></span><i class="material-icons">settings</i>  preferències</a></li>
                        <li><a href="underconstruction.html"><span class="glyphicon"></span><i class="material-icons">lock</i>  canviar password</a></li>
                        <li class="divider"></li>   
                        <li><a href="logout.php"><i class="material-icons" style="font-size:18px">power_settings_new</i>  log out</a></li>
                      </ul>
                    </li>
                  </ul>
                </div> 
              </div>
            </nav>

css是bootstrap的默认值。

1 个答案:

答案 0 :(得分:0)

只需添加这些属性即可将它们对齐在同一行:

.navbar-default .navbar-nav>li>a {
  display: flex;
  align-items: center;
  justify-content: center;
}

希望这有帮助,