简体   繁体   English

Bootstrap Modal:使正文内容全宽

[英]Bootstrap Modal: Make body contents full width of modal

I'm working to create a 'zoom' option on my webapp that will copy a (google) chart into a modal, but I want the chart to expand to the full width of the modal.我正在努力在我的 web 应用程序上创建一个“缩放”选项,该选项会将(谷歌)图表复制到模态中,但我希望图表扩展到模态的全宽。

My plain-vanilla modal:我的普通模式:

<div class="container-fluid">
      <div class="modal fade" id="chartModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
          <div class="modal-content">
            <div class="modal-header">
              <h5 class="modal-title" id="chartModalTitle">-</h5>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">&times;</span>
              </button>
            </div>
            <div id='modalBody' class="modal-body">-</div>
            <div class="modal-footer">
              <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
            </div>
          </div>
        </div>
      </div>
    </div>

and the Javascript that I am using to pluck a chart out of the document:以及我用来从文档中提取图表的 Javascript:

$('.modal-chart').dblclick(function() {
    let chartTitle = this.children.item(0).innerText;
    let chartDiv = this.children.item(1).id;
    chartDiv = '#' + chartDiv;
    $('#chartModal').find('.modal-title').text(chartTitle);
    $('.modal-body').html($(chartDiv).html());
    $('#chartModal').modal('show');
})

I'm wondering where to apply some css to have the chart fill the width of the modal:我想知道在哪里应用一些 css 来让图表填充模态的宽度:

模态图像

you can give position relative to parent div and give position absolute to your Child div您可以提供相对于父 div 的位置,并为您的子 div 提供绝对位置

.modal-body{
 Position:relative;
}
 $(chartDiv).css({top:'0';right:'0';bottom:'0';left:'0';})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM