CSS - 使用带有结果的algolia下拉菜单查看bootstrap navbar的下拉菜单

时间:2017-05-11 12:58:33

标签: javascript html css twitter-bootstrap algolia

我有一个带有搜索表单的导航栏,在那里我可以从Algolia获得自动完成解决方案的结果。这是导航栏:

<nav class="navbar" role="navigation">
    <div class="container">
      <!-- Brand and toggle get grouped for better mobile display -->
      <div class="navbar-header">
        <div id="nav-icon1" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
          <span></span>
          <span></span>
          <span></span>
        </div>
        <a href="{{ url('/') }}">
          <img class="logo logo-small" src="{{ asset('/img/logo-small.png') }}" alt="logo">
          <img class="logo logo-big" src="{{ asset('/img/m2.png') }}" alt="logo">
        </a>
      </div>

      <!-- Collect the nav links, forms, and other content for toggling -->
      <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
        <form action="/search" method="get" class="navbar-form navbar-search-form active" role="search">
          <div class="form-group">
            <div class="input-group">
              <span class="input-group-addon">
                <button type="submit"><i class="ion-ios-search-strong"></i></button>
              </span>
              <input type="text" id="search-input" name="q" class="form-control" placeholder="Search for videos or players..." value="{{ Request::get('q') }}" autofocus>
            </div>
          </div>
        </form>

        <ul class="nav navbar-nav navbar-right">
          <li>
            <a href="{{ url('/login') }}" class="btn btn-primary">Sign in</a>
          </li>
        </ul>
      </div>
      <!-- /.navbar-collapse -->
    </div>
    <!-- /.container-fluid -->
  </nav>

在小屏幕上我遇到问题,结果在导航栏下拉菜单中 enter image description here

我希望他们在下拉菜单中查看。我试过为algolia下拉列表的各种元素设置z-index:

.algolia-autocomplete {
  z-index: 999999 !important;
}

但那不起作用,不确定我应该在哪里更改z-index,因为元素是在自动完成时创建的,所以在输入内容之前我无法看到结构。我该如何解决这个问题?

1 个答案:

答案 0 :(得分:5)

问题出在bootstrap类中:

.navbar-collapse.in {
  overflow-y: auto;
}

我必须将其更改为overflow-y: visible;,然后才有效。