Bootstrap 4 Navbar-Brand Vertical Alignment

时间:2017-11-14 17:34:36

标签: html5 css3 twitter-bootstrap-4

我还没有尝试过任何代码但是想问一下是否有可能有一个带有中心导航栏品牌的导航栏,它位于导板上并与导航栏底部对齐,这样如果品牌增长导航栏没有? / p>

我想将图像的底部与导航栏的底部对齐:

#hdrContainer {
  background-color: #0a3782;
}

.container {
  background-color: inherit;
}

#tblHeader {
  width: 100%;
  /*font-size: .8125rem;*/
  font-size: 1rem;
  text-align: right;
  color: #ffffff;
  font-weight: bold;
}

#tblHeader tr {
  height: 50px;
}

.breadcrumb {
  background-color: inherit;
  margin-bottom: initial;
  font-weight: bold;
}

.breadcrumb .active {
  color: inherit;
}

#socialbrand {
  text-align: right;
}

#mainNavbar {
  background-color: gray;
}

#mainNavbar .container .navbar {
  position: relative;
  z-index: 0;
  max-height: 40px;
}

.navbar-brand {
  position: relative;
  z-index: 1;
  margin-right: initial;
}

.form-control {
  width: 200px;
}

.btn-outline-navy {
  color: #f6b40e;
  background-color: transparent;
  background-image: none;
  border-color: #f6b40e;
}

body {}
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" rel="stylesheet"/>
<body>
  <div id="hdrContainer" class="container-fluid">
    <div class="container">
      <table id="tblHeader">
        <tbody>
          <tr>
            <td>
              <nav aria-label="breadcrumb" role="navigation">
                <ol class="breadcrumb">
                  <li class="breadcrumb-item active" aria-current="page">Commander, Naval Surface Force, US Pacific</li>
                </ol>
              </nav>
            </td>
            <td id="socialbrand" style="display: block; padding: .75rem 1rem;">Follow Us |
              <i class="fa fa-facebook-square" aria-hidden="true"></i>
              <i class="fa fa-twitter-square" aria-hidden="true"></i>
              <i class="fa fa-flickr" aria-hidden="true"></i>
              <i class="fa fa-wordpress" aria-hidden="true"></i>
              <i class="fa fa-youtube-square" aria-hidden="true"></i>
            </td>
          </tr>
          <tr>
            <td colspan="2">
              <nav class="navbar navbar-light">
                <form class="form-inline">
                  <input class="form-control form-control-sm ml-auto mr-sm-2 float-right" type="search" placeholder="Search" aria-label="Search">
                  <button class="btn btn-sm btn-outline-navy my-2 my-sm-0" type="submit">Search</button>
                </form>
              </nav>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
  <div id="mainNavbar" class="container-fluid">
    <div class="container">
      <nav class="navbar navbar-expand-lg navbar-light">
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                        <span class="navbar-toggler-icon"></span>
                    </button>

        <div class="collapse navbar-collapse" id="navbarSupportedContent">
          <ul class="navbar-nav ml-auto 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 dropdown">
              <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown
                                </a>
              <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                <a class="dropdown-item" href="#">Action</a>
                <a class="dropdown-item" href="#">Another action</a>
                <div class="dropdown-divider"></div>
                <a class="dropdown-item" href="#">Something else here</a>
              </div>
            </li>
            <li class="nav-item">
              <a class="nav-link disabled" href="#">Disabled</a>
            </li>
          </ul>
          <!-- Just an image -->
          <a class="navbar-brand mr-auto ml-auto" href="#">
            <img src="https://getbootstrap.com/assets/brand/bootstrap-solid.svg" width="75" height="75" alt="">
          </a>
          <ul class="navbar-nav ml-auto 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 dropdown">
              <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown1" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown
                                </a>
              <div class="dropdown-menu" aria-labelledby="navbarDropdown1">
                <a class="dropdown-item" href="#">Action</a>
                <a class="dropdown-item" href="#">Another action</a>
                <div class="dropdown-divider"></div>
                <a class="dropdown-item" href="#">Something else here</a>
              </div>
            </li>
            <li class="nav-item">
              <a class="nav-link disabled" href="#">Disabled</a>
            </li>
          </ul>
        </div>
      </nav>
    </div>
  </div>
</body>

1 个答案:

答案 0 :(得分:0)

请参阅位置上的W3文档:https://www.w3schools.com/css/css_positioning.asp

我的猜测是你可能想要使用一个位置粘滞的div并将导航栏和品牌放在里面,然后在你希望动画缩小的时候滚动y改变品牌。