在Twitter bootstrap模式中无法获得灰色背景/叠加

时间:2016-04-07 04:01:09

标签: jquery html css twitter-bootstrap bootstrap-modal

Html代码:

<!-- Modal -->
<div class="modal fade" id="az-progress" tabindex="-1" role="dialog" aria-labelledby="Progress bar" data-backdrop="false" data-keyboard="false" data-show="true">
    <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>

使用Javascript:

$(function() {
    $('#az-progress').modal();
});

1 个答案:

答案 0 :(得分:2)

您已指定data-backdrop="false",这将禁用重叠元素。只需删除data-backdrop或指定有效值

即可

&#13;
&#13;
$(function() {
  $('#az-progress').modal({
    modal: true
  });
});
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet" />
<!-- Modal -->
<div class="modal fade" id="az-progress" tabindex="-1" role="dialog" aria-labelledby="Progress bar" data-keyboard="false" data-show="true">
  <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>
&#13;
&#13;
&#13;