简体   繁体   中英

Bootstrap Modal Popup Not Clickable

Using Bootstrap to add a modal popup. Upon clicking the trigger button, the modal is dark and unclickable. Any idea what's causing this or where to look?

在此处输入图像描述

<!-- Button trigger modal -->
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
  Launch demo modal
</button>


<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title" id="myModalLabel">Modal title</h4>
      </div>
      <div class="modal-body">
        ...
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div>
  </div>
</div>

application.js

//= require jquery
//= require jquery.turbolinks
//= require jquery_ujs
//= require miracle/jquery.noconflict
//= require miracle/modernizr.2.8.3.min
//= require miracle/jquery-migrate-1.2.1.min
//= require miracle/jquery-ui.1.11.2.min
//= require bootstrap
//= require turbolinks
//= require magnific-popup/jquery.magnific-popup.min
//= require miracle/jquery.stellar.min
//= require miracle/waypoints.min
//= require owl-carousel/owl.carousel.min
//= require jquery.sky.carousel/jquery.sky.carousel-1.0.2
//= require miracle/jquery.plugins
//= require miracle/main
//= require_tree .

当我在模态中添加 data-backdrop="false" 时,我解决了同样的问题,如下所示:

<div class="modal fade" id="userGoing" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop="false">

Sometimes, changing the z-index can mess up things with Bootstrap so as they say in Bootstrap documentation , try to place your <!-- Modal --> block on top of your page. If it's a modal that is accessible from many places in your app you can place it in a partial and call it on top of your app/views/layouts/application.html.erb like so (sorry, it's a slim template, tell me if you need erb translation):

doctype html
html
  head
    == render 'layouts/meta'

    = stylesheet_link_tag …
    = javascript_include_tag …
    = csrf_meta_tags

  body

    == render 'path/to/your/modal'

    .container
      == yield

    == render 'layouts/footer'

Otherwise, you could try to do a special <%== yield :modal %> in your application.html.erb and call it from somewhere else with `<%- content_for :modal %>. Not sure about the erb syntax here. It's explained here : Using The Content For Method

Add the below code in the same page.

#myModal{
 z-index: 9999
}

I had the same problem when I call a modal from another modal (but not when I call only the first one).

So, this might not help you but it can save someone else a lot of time: I had a different definition of fade effects and there was the line with display: inline-block . I removed it and the problem's gone.

The failing CSS definition:

.fade {
    ...
    display: inline-block;
    ...
}

After long time, i got this simple error just by

.modal-backdrop {
    z-index: -1;
}

Thanks.

.modal-dialog has pointer-events set to none .

I overwrote that property and set pointer-events: unset;

so:

.modal-dialog {
  pointer-events: unset !important;
}

This did the trick for me

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM