簡體   English   中英

模態顯示在數據表后面

[英]Modal displaying behind datatable

查看編輯:

我有一個模態,我試圖遍歷並在每次循環中顯示。 到目前為止,我有以下代碼,我正在嘗試使模式顯示在按鈕單擊上。 到目前為止,它還不充當模式,而是顯示在按鈕正下方。 我覺得我可能缺少javascript,但似乎找不到在線使用的正確東西。 我認為這可能很容易,而且我只是想念一些東西。 任何幫助都會很棒,我仍然是新來的! 謝謝!

  <label class="btn" for="modal-x">Add Map</label>

  <input class="modal-state" id="modal-x" type="checkbox" />
    <div class="modal">
      <label class="modal__bg" for="modal-x"></label>
      <div class="modal__inner">
        <label class="modal__close" for="modal-x"></label>
        <h1>Add Mapfile</h1>
        <%= form_for(@posts, multipart: true) do |f| %>
          <div class="field">
            <%= f.hidden_field :location_id, :value => @location.id%>
          </div>
          <div class="field">
            <%= f.file_field :mapfile %>
          </div>
          <p></p>
          <div class="actions" id="submit-map">
            <%= f.submit 'Submit' %>
          </div>
        <%end %>
      </div>
    </div>

編輯 :我已經想出了如何使模態工作,但現在它顯示在我正在使用的數據表的后面,而不是在它上面/前面。 是否有我可以更改的屬性,可以使模式出現在最前面?

這是我的CSS:

.modal {
  opacity: 0;
  visibility: hidden;  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  text-align: left;
  background: rgba(0,0,0, .9);
  transition: opacity .25s ease;
}

.modal__bg {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  cursor: pointer;
}

.modal-state {
  display: none;
}

.modal-state:checked + .modal {
  opacity: 1;
  visibility: visible;
}

.modal-state:checked + .modal .modal__inner {
  top: 0;
}

.modal__inner {
  transition: top .25s ease;
  position: absolute;
  top: -20%;
  right: 0;
  bottom: 0;
  left: 0;
  width: 50%;
  margin: auto;
  overflow: auto;
  background: #fff;
  border-radius: 5px;
  padding: 1em 2em;
  height: 50%;
}

.modal__close {
  position: absolute;
  right: 1em;
  top: 1em;
  width: 1.1em;
  height: 1.1em;
  cursor: pointer;
}

.modal__close:after,
.modal__close:before {
  content: '';
  position: absolute;
  width: 2px;
  height: 1.5em;
  background: #ccc;
  display: block;
  transform: rotate(45deg);
  left: 50%;
  margin: -3px 0 0 -1px;
  top: 0;
}

.modal__close:hover:after,
.modal__close:hover:before {
  background: #aaa;
}

.modal__close:before {
  transform: rotate(-45deg);
}

@media screen and (max-width: 768px) {

  .modal__inner {
    width: 90%;
    height: 90%;
    box-sizing: border-box;
  }
}

將您的div模態包裝到另一個div中,否則循環中的其他按鈕將不會出現。

確保加載引導css和引導js。

在您的gem文件中有這個。

gem 'bootstrap-sass', '~> 3.3.5'

並在您的application.css中

@import "bootstrap-sprockets";
@import "bootstrap";

而且您的application.js應該看起來像這樣

//= require jquery
//= require jquery_ujs
//= require bootstrap-sprockets
//= require turbolinks
//= require_tree .

試試這個,然后重新啟動服務器。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM