网格堆叠在模态弹出窗口中

Grids getting stacked inside the modal pop-up

我在 bootstrap 模态弹出窗口中有 5 个网格。

当我点击弹出按钮时,网格堆叠在 other.When 我拖动一个网格,整个 5 个网格正在累积 properly.Once 这是 done.It 有效下次点击弹出按钮就可以了。

代码如下

<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>

<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Modal Header</h4>
      </div>
      <div class="modal-body">
        <h1>Image sort</h1>
<div class="packery">
  <div class="item w2 h2 i1" tabindex="0">A</div>
  <div class="item w2 h2 i2" tabindex="1">B</div>
  <div class="item w2 h2 i3" tabindex="2">C</div>
  <div class="item w2 h2 i4" tabindex="3">D</div>
  <div class="item w2 h2 i5" tabindex="4">E</div>
</div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div>

Fiddle Demo here

只需将代码放入 bootstrap 模态事件侦听器,以便在模态显示后初始化

$(document).ready(function(){
    $('#myModal').on('shown.bs.modal', function () {
        // grid code
     });
});

Fiddle