0
ブートストラップモーダルの幅を画面の幅の75%に設定し、水平に中央に置く手助けができますか?これまで私が試してみました:ブートストラップのモーダル幅を画面のパーセントに設定して中央に設定する
<div class="container">
<!-- Modal -->
<div class="modal fade" id="mymodal" tabindex="-1" role="dialog" aria-labelledby="createTemplateModal" aria-hidden="true">
<div class="modal-dialog" role="document">
<!--Content-->
<div class="modal-content">
<!--Header-->
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title" id="myModalLabel">My Modal</h4>
</div>
<!--Body-->
<div class="modal-body">
<h1>
Modal Body
</h1>
<!--Footer-->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
$('#mymodal').modal('toggle');
$('#mymodal').on('shown.bs.modal', function() {
var width = $(window).width() * 0.75;
console.log('width is: ' + width);
$(this).find(".modal-body").css("width", width);
});
しかし、この1は)私の画面の幅の75%の幅を設定しないと、2)それがオーバーフロー水平モーダル体の内容の一部になります。ここに私のバイブルです:http://jsfiddle.net/dc46o5p9/
ありがとうございます!
だけCSSを使用して、それが正常に動作JSを記述する必要はありません。 – aavrug
これを試してみてくださいhttp://jsfiddle.net/aavrug/g2ghb87r/5/ – aavrug
完璧に、ありがとう! –