Z-index:物化选择总是在后台打开

时间:2017-01-19 04:18:04

标签: javascript css ruby-on-rails materialize

所以我使用materialize css select来设置表单中的下拉列表。但是,当我登陆我的页面时,下拉列表始终是"隐藏打开"。更具体地说,如果我将悬停在下面"驻留"下拉到空白区域,甚至进入表单的后半部分,然后单击,它将更改下拉列表的值。摆脱它的唯一方法是打开下拉并关闭它。为什么会这样?有什么建议吗?

关闭的无序列表的Z-index是999.当我将其更改为-1时,它会消失但是当我打开下拉列表时,它会在所有其他文本后面。

enter image description here

1 个答案:

答案 0 :(得分:0)

我添加了一个名为 wrapper 的div,并修改了页眉和页脚位置。我还在页眉高度中添加了包装div中的填充,与页脚的情况相同。

希望这会有所帮助

<强> HTML:

<div class="wrapper" style="overflow-y: auto;overflow-x: hidden;padding-top: 34px;padding-bottom: 126px;">
  <header id='header'>Test 0.1</header>
  <aside id='aside'>
    <p>Menu 1</p>
    <p>Menu 2</p>
    <p>Menu 3</p>
    <p>Menu 4</p>
    <p>
      <span id='spn'>n</span>
    </p>
  </aside>
  <section>
    <div id='divMain'>
      <table>
        <tr>
          <th>Col1</th>
          <th>Col2</th>
          <th>Col3</th>
        </tr>
        <tr>
          <td>A</td>
          <td>B</td>
          <td>C</td>
        </tr>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
        </tr>
        <tr>
          <td>A</td>
          <td>B</td>
          <td>C</td>
        </tr>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
        </tr>
        <tr>
          <td>A</td>
          <td>B</td>
          <td>C</td>
        </tr>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
        </tr>
        <tr>
          <td>A</td>
          <td>B</td>
          <td>C</td>
        </tr>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
        </tr>
        <tr>
          <td>A</td>
          <td>B</td>
          <td>C</td>
        </tr>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
        </tr>
        <tr>
          <td>A</td>
          <td>B</td>
          <td>C</td>
        </tr>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
        </tr>
        <tr>
          <td>A</td>
          <td>B</td>
          <td>C</td>
        </tr>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
        </tr>
        <tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
        </tr><tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
        </tr><tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
        </tr><tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
        </tr><tr>
          <td>1</td>
          <td>2</td>
          <td>3</td>
        </tr>
      </table>
    </div>
  </section>
  <footer id='footer'>Address,
    <br>phone,
    <br>etc.
    <br>
    <br>Address,
    <br>phone,
    <br>etc.
    </footer>
</div>

<强> CSS:

html,
body {
  height: 100%;
  margin: 0;
  overflow-x: hidden;
  overflow-y: hidden;
}

body {
    position: relative;
    padding-top: 0;
    overflow-y: auto;
}

header {
      background-color: green;
    color: white;
    text-align: center;
    font-weight: bold;
    font-size: 30px;
    position: fixed;
    width: 100%;
    top: 0;
}

section {
  float: right;
  width: 80%;
  overflow-x: auto;
  overflow-y: auto;
}

section div {
  padding: 10px;
  overflow-x: auto;
  overflow-y: auto;
}

aside {
  float: left;
  background-color: lightgreen;
  width: 20%;
}

aside p {
  margin-left: 20px;
}

footer {
    background-color: green;
    color: white;
    text-align: center;
    clear: both;
    position: fixed;
    bottom: 0;
    width: 100%;
}

table {
  border-collapse: collapse;
}

th {
  border: 1px solid black;
  text-align: center;
  font-weight: bold;
}

td {
  border: 1px solid black;
  text-align: center;
}