图片不会移到导航栏的左侧

时间:2019-04-29 19:50:58

标签: html5 bootstrap-4 navbar nav

我正在尝试将图像“ travel.png”放置在导航栏的左侧,就像它在屏幕的左侧一样。

https://imgur.com/a/I0xFOWc

PUT _xpack/security/role_mapping/GROUPNAME
{
    "roles" : [
      "reader"
    ],

    "rules" : {
      "field" :
        {
          "groups" : ["INFO1","INFO2"]
        }
    },
    "enabled": true
}

1 个答案:

答案 0 :(得分:1)

我不清楚,问题出在哪里;测试您的代码,看起来图像应该是它​​应该在的地方,但是,如果您指的是图像在屏幕上稍微居中,那是因为导航栏中有.container元素,将其删除使导航栏使用屏幕的全部可用宽度。

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
  <div class="container">
    <a class="navbar-brand" href="travelindex.html">
      <img src="https://via.placeholder.com/30" class="" alt="">
    </a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>
    <div class="collapse navbar-collapse" id="navbarResponsive">
      <ul class="navbar-nav ml-auto">
        <li class="nav-item active">
          <a class="nav-link" href="travelindex.html">Home
                <span class="sr-only">(current)</span>
              </a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="reservations.html">Reservations</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="aboutus.html">About Us</a>
        </li>
      </ul>
    </div>
  </div>
</nav>

没有container

<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet" />
<!-- Without container -->
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
  <a class="navbar-brand" href="travelindex.html">
    <img src="https://via.placeholder.com/30" class="" alt="">
  </a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
          <span class="navbar-toggler-icon"></span>
        </button>
  <div class="collapse navbar-collapse" id="navbarResponsive">
    <ul class="navbar-nav ml-auto">
      <li class="nav-item active">
        <a class="nav-link" href="travelindex.html">Home
                <span class="sr-only">(current)</span>
              </a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="reservations.html">Reservations</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="aboutus.html">About Us</a>
      </li>
    </ul>
  </div>
</nav>