【问题标题】:Remove all padding from bootstrap modal从引导模式中删除所有填充
【发布时间】:2017-11-27 17:35:21
【问题描述】:

您好,我如何从引导模式中删除所有填充和边距、页脚和页眉空间。我只想看到身体完全符合我的内容。 提前致谢。正在使用引导程序 3?我没有使用页眉和页脚元素。只有模态,模态对话框,模态内容和模态。到目前为止,我有以下内容,但我的内容周围仍有空间。

.modal-body {
    position: relative;
    overflow-y: auto;
    margin: 0 ;
    padding: 0;
}
.modal-content{
    padding: 0;
    margin: 0;
}

HTML

            <div class="modal  fade" id="tpModal3" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
                 aria-hidden="false">
                <div class="modal-dialog " role="document">
                    <div class="modal-content">

                        <div class="modal-body">
                            <mycontent></mycontent>
                        </div>

                    </div>
                </div>
            </div>

【问题讨论】:

    标签: javascript html css twitter-bootstrap-3 bootstrap-modal


    【解决方案1】:

    解决方案是使用jquery,并在modaltriggered时设置css属性。

    为此,您应该处理shown.bs.modal 事件。

    $('.modal').on('shown.bs.modal', function() {
       $(".modal-body").css("padding",'0px');
       $(".modal-body").css("margin",'0px');
       $(".modal-dialog").css({
                  'position': 'relative',
                  'display': 'table',
                  'overflow-y': 'auto',    
                  'overflow-x': 'auto',
                  'width': 'auto',
                  'min-width': '10px'
       });
    });
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
    <!-- Button trigger modal -->
    <button type="button" id="mymodal" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
      Launch demo modal
    </button>
    
    <!-- Modal -->
    <div class="modal" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
      <div class="modal-dialog" role="document">
        <div class="modal-content">
          <div class="modal-body">
            Lorem lorem lorem
          </div>
        </div>
      </div>
    </div>

    【讨论】:

    • 上面的小提琴似乎有一个固定的宽度。将文本缩减为一个单词并查看
    • @flexxxit,看看我的回答。
    猜你喜欢
    • 2013-03-27
    • 2020-12-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-04
    • 2015-11-11
    • 1970-01-01
    • 2013-05-09
    相关资源
    最近更新 更多