如果高度超过浏览器,将 Bootstrap 模式内容设置为滚动 [英] Set Bootstrap modal content to scroll if height exceeds browser
问题描述
我看到很多人问这个问题,但没有真正可靠的答案.
如果模态的高度超过浏览器的内部高度,我希望红色边框的 Div 有一个滚动条,使模态保持在浏览器视图中.
#scrollbox {边框:1px纯红色;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css"><script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script><input type="button" data-toggle="modal" data-target="#myModal" value="Launch Modal"><div class="modalfade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"><div class="modal-dialog" role="document"><div class="modal-content"><div class="modal-body">你好,下面是 div 中的一些文本,如果模态的高度超过浏览器,它应该开始滚动.<p><div id="scrollbox"><br>快速<br>棕色<br>狐狸<br><br>快速<br>棕色<br>狐狸<br><br>快速<br>棕色<br>狐狸<br><br>快速<br>棕色<br>狐狸<br><br>快速<br>棕色<br>狐狸<br><br>快速<br>棕色<br>狐狸<br><br>快速<br>棕色<br>狐狸<br><br>快速<br>棕色<br>狐狸<br><br>快速<br>棕色<br>狐狸<br><br>快速<br>棕色<br>狐狸<br>