简体   繁体   English

如何为模态窗口内呈现的局部视图添加滚动条

[英]how to add a Scroll bar for a partial view rendered inside a modal window

I have the following Script and markup to render a partial view inside a modal popup:- 我有以下脚本和标记可在模式弹出窗口中呈现部分视图:-

  $(function () {
        $.ajaxSetup({ cache: false });
        $("a[data-modal]").on("click", function (e) {        
            $('#myModalContent').load(this.href, function () {
                $('#myModal').modal({
                    keyboard: true
                }, 'show');

                bindForm(this);
            });
            return false;
        });


    });
<!-- modal placeholder-->
<div id='myModal' class='modal fade in'>
    <div class="modal-dialog">
        <div class="modal-content">
            <div id='myModalContent'></div>
        </div>
    </div>
</div>

but can i force the modal window to show a vertical scroll bar , if the partial view content exceed certain height ? 但是,如果部分视图内容超过特定高度,我是否可以强制模式窗口显示垂直滚动条?

  • Set a max-height property on your modal window to prevent it from exceeding a certain height. 在模态窗口上设置max-height属性,以防止其超过特定高度。
  • Then set overflow-y: auto on your modal window to have a vertical scroll bar pop up if the content exceeds the height. 然后,在模式窗口上设置overflow-y:auto ,以在内容超出高度时弹出垂直滚动条。
  • To force the vertical scroll bar to show up regardless of whether the content overflows, set it to overflow-y: scroll instead. 要强制显示垂直滚动条,而不管内容是否溢出,请将其设置为overflow-y:改为滚动

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

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