Twitter Bootstrap 3 Modal with Scrollable Body

前端 未结 3 1152
没有蜡笔的小新
没有蜡笔的小新 2021-01-31 09:38

I am moving from Bootstrap 2 to Bootstrap 3. In the old version, I was using modals which had long content, and the modals automatically scrolled when a given max height was rea

3条回答
  •  借酒劲吻你
    2021-01-31 10:12

    If you have dynamic content this can be a pain. I used this to make sure it had the correct height and then it would scroll:

    $('#modal').on('shown.bs.modal', function () {
      $('.modal-dialog').css('height', $('.modal-dialog').height() );
    });
    
    $('#modal').on('hidden.bs.modal', function () {
      $('.modal-dialog').css('height', 'auto');
    });
    

提交回复
热议问题