CSS - 如何从div中获取一个元素,其中z-index小于具有更高z-index的另一个div的内容

时间:2017-09-09 14:09:44

标签: css algolia

如果可能的话,我怎样才能获得div中的一个元素,其中z-index低于具有更高z-index的div的内容? 在我的模板中,我有一个页面上所有内容的包装器,以及隐藏在右侧的非画布菜单:

@section('head')
  @include('public.layouts.partials._head')
@show
@include('public.layouts.partials._menu')
<div id="wrapper">
  <div id="main">
    @include('public.layouts.partials._navigation')
      @yield('content')
    @include('public.layouts.partials._footer')
  </div>
</div>

在我的导航部分中,我有一个带有algolia自动完成功能的输入字段:

   <div class="form-wrapper">
     <form action="/search" method="get">
       <div class="input-group">
         <span class="input-group-addon">
           <button type="submit" class="search-button">
             <i class="ion-ios-search-strong"></i>
           </button>
         </span>
         <input type="text" name="q" class="search-input search-input-small-js form-control aa-input-search" placeholder="Search for players and videos ..." aria-describedby="basic-addon1">
       </div>
     </form>
   </div>

我遇到的问题是,当我打开菜单时,如果我在字段中输入内容,结果将显示在菜单下方。我想做的是以某种方式,如果可能的话,从页面上所有内容上方的自动填充字段显示下拉菜单。 这是非画布菜单的CSS:

body {
    overflow-x: hidden
}
#wrapper {
    position: relative;
    z-index: 10;
    top: 0;
    left: 0;
    -webkit-transition: all 0.4s;
    -moz-transition: all 0.4s;
    -ms-transition: all 0.4s;
    -o-transition: all 0.4s;
    transition: all 0.4s;
}
.menu {
    position: fixed;
    z-index: 20;
    overflow: hidden;
    -webkit-transition: all 0.4s;
    -moz-transition: all 0.4s;
    -ms-transition: all 0.4s;
    -o-transition: all 0.4s;
    transition: all 0.4s;
        color: $dark-green;
        padding: 45px;
        padding-top: 3rem;
        background: $black-menu-bg;
        a {
            color: $light-gray;
        }
        h4 {
            margin-top: 10px;
        }
        .btn {
        margin-top: 1rem;
      }
}
.push-menu-left {
    top: 50px;
    width: 280px;
    height: 100%;
        box-shadow: 4px 2px 3px hsla(0,0%,4%,.5);
}
.push-menu-left {
    right: -285px;
}
body.pml-open .push-menu-left {
    right: 0;
}
body.pml-open #wrapper {
    right: 280px;
}

这是自动填充字段的css:

.algolia-autocomplete {
  display: flex!important;
  flex: auto!important;
}
.aa-dropdown-menu {
  position: relative;
  top: -6px;
  border-radius: 3px;
  margin: 6px 0 0;
  padding: 0;
  text-align: left;
  height: auto;
  position: relative;
  background: $white;
  border: 1px solid #ccc;
  width: 100%;
  left: 0 !important;
  box-shadow: 0 1px 0 0 rgba(0, 0, 0, 0.2), 0 2px 3px 0 rgba(0, 0, 0, 0.1);
}

.aa-dropdown-menu:before {
  position: absolute;
  content: '';
  width: 14px;
  height: 14px;
  background: #fff;
  z-index: 0;
  top: -7px;
  border-top: 1px solid #D9D9D9;
  border-right: 1px solid #D9D9D9;
  transform: rotate(-45deg);
  border-radius: 2px;
  z-index: 999;
  display: block;
  left: 24px;
}

.aa-dropdown-menu .aa-suggestions {
  position: relative;
  z-index: 1000;
}

.aa-dropdown-menu [class^="aa-dataset-"] {
  position: relative;
  border: 0;
  border-radius: 3px;
  overflow: auto;
  padding: 8px 8px 8px;
  color: #3c3e42;
  font-weight: 500;
}

.aa-dropdown-menu * {
  box-sizing: border-box;
}

.aa-suggestion {
  padding: 0 4px 0;
  display: block;
  width: 100%;
  height: 38px;
  clear: both;
}
.aa-suggestion span {
  white-space: nowrap !important;
  text-overflow: ellipsis;
  overflow: hidden;
  display: block;
  float: left;
  line-height: 1em;
  width: calc(100% - 30px);
}
.aa-suggestion.aa-cursor {
  background-color: transparent;
}
.aa-suggestion em {
  color: #00bcd4;
  font-weight: 700;
}
.aa-suggestion img {
  float: left;
  height: 44px;
  width: 44px;
  margin-right: 6px;
}

.aa-suggestion a {
  color: #3c3e42;
}

.aa-suggestions-category {
  font-weight: 700;
  color: #3c3e42;
  border-bottom: 1px solid rgba(102, 105, 105, 0.17);
}

.powered-by-algolia {
  padding-left: 15px;
  border-top: 1px solid rgba(102, 105, 105, 0.17);
  display: flex;
  align-items: center;
  height: 30px;
}

.aa-input-container {
  display: inline-block;
  position: relative; }
.aa-input-search {
  width: 100%;
  height: 100%;
  padding: 12px 28px 12px 12px;
  box-sizing: border-box;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none; }
.aa-input-search::-webkit-search-decoration, .aa-input-search::-webkit-search-cancel-button, .aa-input-search::-webkit-search-results-button, .aa-input-search::-webkit-search-results-decoration {
  display: none;
}
.media {
  margin: 10px 0;
}
.media-body {
  p {
    margin: 0;
  }
}

有没有办法实现这个目标?

0 个答案:

没有答案