Bootstrap実現modal中央

1738 ワード

Bootstrap version: 3.1.1
 
<div class="modal fade" id="revECheModal" tabindex="-1" role="dialog" aria-labelledby="revECheModTitle" aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h4 class="modal-title" id="revECheModTitle">Revoke Cheque No.</h4>
      </div>
      <form id="otpForm" role="form">
        <div class="modal-body">
          <div class="form-group">
            <br>Are you sure to revoke this e-cheque ?</div>
        </div>
        <div class="modal-footer">
          <button type="button" class="btn btn-primary">Confirm</button>
          <button type="button" class="btn btn-default" data-dismiss="modal">&nbsp;Close&nbsp;</button>
        </div>
      </form>
    </div>
  </div>
</div>

  
$("div[role='dialog']").on("show.bs.modal", function() {
    //  css 
    $(this).css({
        "display": "block",
        "margin-top": function() {
            return ($(this).height() / 3);
        }
    });
});