這篇文章將為大家詳細講解有關bootstrap如何解決多層模態框滾動條消失的問題,小編覺得挺實用的,因此分享給大家做個參考,希望大家閱讀完這篇文章后可以有所收獲。
bootstrap 打開多層模態框的情況下,關閉任意一個模態框,都會導致其余模態框的滾動條消失。
監測html發現,當打開模態框時,會給 body 元素加一個 modal-open 的 class,而在 bootstrap.css 中,有這樣一條 css 規則:
.modal-open .modal {overflow-x:hidden; overflow-y:auto}因為有 overflow-y:auto,所以模態框才可以滾動,而當關閉任何一個模態框時,body 元素的 css 規則 modal-open 會被移除掉,自然 overflow-y:auto 也就沒有了,所以模態框的滾動條就消失了。
解決方案是在模態框的 div 元素上加一條 ,如下:
<div class="modal fade" ... >
這樣,模態框的滾動就不依賴 body 元素的 css 規則 modal-open 了。
實例
<div class="modal fade" id="myModal2" data-backdrop="static" <span ></span> popover-page-id="CS040104"> <div class="modal-dialog modal-1200"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> <h5 class="modal-title" id="myModalLabel">模態框(Modal)標題222</h5> </div> <div class="modal-body" >在這里添加一些文本</div> <div class="modal-footer"> <button type="button" class="btn btn-success" data-toggle="modal" target="modal" data-target="#myModal3">模態框</button> <button type="button" class="btn btn-default" data-dismiss="modal">關閉</button> <button type="button" class="btn btn-primary">提交更改</button> </div> </div> <!-- /.modal-content --> </div> <!-- /.modal --> </div>
關于“bootstrap如何解決多層模態框滾動條消失的問題”這篇文章就分享到這里了,希望以上內容可以對大家有一定的幫助,使各位可以學到更多知識,如果覺得文章不錯,請把它分享出去讓更多的人看到。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。