阻止modal隐藏materializecss中的滚动条

时间:2017-12-10 10:52:12

标签: html css materialize

每当我从Materialisecss打开一个模态时,滚动条(我的身体都有内联滚动条)每次都会隐藏。我该怎么办,每当我打开一个模态时,身体的滚动条会保留下来?

<body>
        <div id="modal_confirm_block" class="modal modal_dialog">
            <div class="modal-content white" id="modal_confirm_co_content" style="padding:0px !important;">
                <div id="div_available" class="center-align" style="padding: 20px !important;"> <i class="material-icons md-12 noselect center-align amber-text darken-4" > warning</i><br>
                    <p style="padding:20px !important;" class="center-align"> Are you sure you want to block this guest? </p>
                </div>
            </div>
            <div class="modal-footer">
                <div class="row" style="margin: 0 !important;">
                    <div class="col s6"> <a href="#!" id="btn_confirm_block" class=" cyan darken-2 white-text modal-action waves-effect waves-white btn" style="width:100% !important;">Confirm</a></div>
                    <div class="col s6">    <a href="#!" id="btn_cancel_block" class="blue-grey darken-4 white-text  modal-action modal-close waves-effect waves-white btn" style="width:100% !important; ">Cancel</a></div>
                </div>
            </div>
        </div>
    </body>

Screenshot before opening a modal
Screenshot when a modal opens. Look at the scrollbar it was removed. And I don't like that because the screen always move.

1 个答案:

答案 0 :(得分:0)

对我来说,它是通过将这种方式放在CSS中来实现的。

body {
   overflow: scroll !important
}