bootstrap 彈出框點(diǎn)擊其他區(qū)域時(shí)彈出框不消失選項(xiàng)設(shè)置

bootstrap by 黃業(yè)興 at 2020-04-29

默認(rèn)情況下,bootstrap 彈出框點(diǎn)擊其他區(qū)域時(shí),彈出框會(huì)自動(dòng)關(guān)閉,在很多時(shí)候,我們可能會(huì)希望達(dá)到和原生彈出框一樣的效果,避免不小心點(diǎn)擊其他區(qū)域時(shí)彈框自動(dòng)隱藏,尤其是對于一些復(fù)雜的表單,重復(fù)填寫可能會(huì)帶來很不好的體驗(yàn)效果,所以,我們會(huì)希望不會(huì)發(fā)生這種情況。如下所示:

<div class="modal fade" id="myModal" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                <h4 class="modal-title" id="myModalLabel">模態(tài)框(Modal)標(biāo)題</h4>
            </div>
            <div class="modal-body">按下 ESC 按鈕退出。</div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">關(guān)閉</button>
                <button type="button" class="btn btn-primary">提交更改</button>
            </div>
        </div>
    </div>
</div>

上面這段代碼就可以實(shí)現(xiàn)這個(gè)效果,主要是在modal添加這段代碼

data-backdrop="static"

請關(guān)注我們微信公眾號:mw748219