欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

bootstrap modal 垂直居中對齊

系統 2196 0

文章參考

http://www.bubuko.com/infodetail-666582.html

http://v3.bootcss.com/javascript/#modals

?

      <div class="modal fade" id="sqh_model">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">蔬菜預約</h4>
            </div>
            <div class="modal-body">
                <p>盡請期待</p>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">關閉</button>
                <button type="button" class="btn btn-primary" data-dismiss="modal">確定</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->


function showTips(){
	$('#sqh_model').modal('show')
}
    

?

?

默認是距離頂部30px,左右居中

如圖所示

bootstrap modal 垂直居中對齊

?

解決辦法一:覆蓋之前的CSS樣式

      /**********對bootstrap的modal樣式進行重寫**********/
.modal-dialog {
    margin: 200px auto;
}
    

?

?

解決辦法二:調用回調函數

?

      function showTips(){
        //{"backdrop":"static"}點擊背景不會消失
        $('#sqh_model').modal({"backdrop":"static"}).modal('show').on("shown.bs.modal",function(){
            // 是彈出框居中。。。
            var $modal_dialog = $(this.$element[0]).find('.modal-dialog');
            //獲取可視窗口的高度
            var clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight: document.documentElement.clientHeight;
            //得到dialog的高度
            var dialogHeight = $modal_dialog.height();
            //計算出距離頂部的高度
            var m_top = (clientHeight - dialogHeight)/2;
            console.log("clientHeight : " + clientHeight);
            console.log("dialogHeight : " + dialogHeight);
            console.log("m_top : " + m_top);
            $modal_dialog.css({'margin': m_top + 'px auto'});
        });
    }
    

?

解決辦法三:修改源代碼

      Modal.prototype.adjustDialog = function () {
    var modalIsOverflowing = this.$element[0].scrollHeight > document.documentElement.clientHeight

    this.$element.css({
      paddingLeft:  !this.bodyIsOverflowing && modalIsOverflowing ? this.scrollbarWidth : '',
      paddingRight: this.bodyIsOverflowing && !modalIsOverflowing ? this.scrollbarWidth : ''
    });

    // 是彈出框居中。。。
    var $modal_dialog = $(this.$element[0]).find('.modal-dialog');
    //獲取可視窗口的高度
    var clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight: document.documentElement.clientHeight;
    //得到dialog的高度
    var dialogHeight = $modal_dialog.height();
    //計算出距離頂部的高度
    var m_top = (clientHeight - dialogHeight)/2;
    console.log("clientHeight : " + clientHeight);
    console.log("dialogHeight : " + dialogHeight);
    console.log("m_top : " + m_top);
    $modal_dialog.css({'margin': m_top + 'px auto'});
}
    

?

?

參數

可以將選項通過 data 屬性或 JavaScript 代碼傳遞。對于 data 屬性,需要將參數名稱放到? data- ?之后,例如? data-backdrop=""

名稱 類型 默認值 描述
backdrop boolean 或 字符串 'static' true

Includes a modal-backdrop element. Alternatively,

specify? static ?for a backdrop which doesn't close

the modal on click.

keyboard boolean true 鍵盤上的 esc 鍵被按下時關閉模態框。
show boolean true 模態框初始化之后就立即顯示出來。
remote path false

This option is deprecated since v3.3.0 and will be

removed in v4. ?We recommend instead using

client-side templating or a data binding framework,

or calling? jQuery.load yourself.

如果提供的是 URL,將利用 jQuery 的? load ?方法 從此

URL 地址加載要展示的內容(只加載一次)

插入? .modal-content ?內。如果使用的是 data 屬性 API,

還可以利用? href ?屬性指定內容來源地址。下面是一個實例:

復制
                  
                    
                      <a
                    
                    
                      data-toggle=
                    
                    
                      "modal"
                    
                    
                      href=
                    
                    
                      "remote.html"
                    
                    
                      data-target=
                    
                    
                      "#modal"
                    
                    
                      >
                    
                    Click me
                    
                      </a>
                    
                  
                

方法

.modal(options)

將頁面中的某塊內容作為模態框激活。接受可選參數? object

復制
        
          
            $
          
          
            (
          
          
            '#myModal'
          
          
            ).
          
          
            modal
          
          
            ({
          
          
            keyboard
          
          
            :
          
          
            false
          
          
            })
          
        
      

.modal('toggle')

手動打開或關閉模態框。 在模態框顯示或隱藏之前返回到主調函數中 (也就是,在觸發? shown.bs.modal ?或 hidden.bs.modal ?事件之前)。

復制
        
          
            $
          
          
            (
          
          
            '#myModal'
          
          
            ).
          
          
            modal
          
          
            (
          
          
            'toggle'
          
          
            )
          
        
      

.modal('show')

手動打開模態框。 在模態框顯示之前返回到主調函數中 ?(也就是,在觸發? shown.bs.modal ?事件之前)。

復制
        
          
            $
          
          
            (
          
          
            '#myModal'
          
          
            ).
          
          
            modal
          
          
            (
          
          
            'show'
          
          
            )
          
        
      

.modal('hide')

手動隱藏模態框。 在模態框隱藏之前返回到主調函數中 ?(也就是,在觸發? hidden.bs.modal ?事件之前)。

復制
        
          
            $
          
          
            (
          
          
            '#myModal'
          
          
            ).
          
          
            modal
          
          
            (
          
          
            'hide'
          
          
            )
          
        
      

.modal('handleUpdate')

Readjusts the modal's positioning to counter a scrollbar in case one should appear, which would make the modal jump to the left.

Only needed when the height of the modal changes while it is open.

復制
        
          
            $
          
          
            (
          
          
            '#myModal'
          
          
            ).
          
          
            modal
          
          
            (
          
          
            'handleUpdate'
          
          
            )
          
        
      

事件

Bootstrap 的模態框類提供了一些事件用于監聽并執行你自己的代碼。

All modal events are fired at the modal itself (i.e. at the? <div class="modal"> ).

事件類型 描述
show.bs.modal

show ?方法調用之后立即觸發該事件。如果是通過點擊某個作為觸發器

的元素,則此元素可以通過事件的 relatedTarget ?屬性進行訪問。

shown.bs.modal

此事件在模態框已經顯示出來(并且同時在 CSS 過渡效果完成)之后被觸發。

如果是通過點擊某個作為觸發器的元素,則此元素可以通

過事件的? relatedTarget ?屬性進行訪問。

hide.bs.modal hide ?方法調用之后立即觸發該事件。
hidden.bs.modal 此事件在模態框被隱藏(并且同時在 CSS 過渡效果完成)之后被觸發。
loaded.bs.modal 遠端的數據源 加載完數據之后觸發該事件。
復制
        
          
            $
          
          
            (
          
          
            '#myModal'
          
          
            ).
          
          
            on
          
          
            (
          
          
            'hidden.bs.modal'
          
          
            ,
          
          
            function
          
          
            (
          
          
            e
          
          
            )
          
          
            {
          
          
            // do something...
          
          
            })
          
        
      

bootstrap modal 垂直居中對齊


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 伊人亚洲 | www.久久 | 特黄特色大片免费高清视频 | 午夜视频在线观看网站 | 伊人久久大杳蕉综合大象 | 久草电影网站 | 亚洲品质自拍视频 | 婷婷色九月综合激情丁香 | 日本妇人成熟免费不卡片 | 国产亚洲精品久久久久久久网站 | 亚洲入口 | 九九精品视频一区在线 | jizzjizz视频| 亚洲第一成人在线 | 精品中文字幕在线观看 | 亚洲成人福利在线观看 | 成人在线不卡视频 | 久久久久无码国产精品一区 | 12306播播影院午夜 | 综合久久99 | 久久综合九色综合欧美狠狠 | 白色白色视频免费观看 | 国产一区在线观看视频 | 成人日韩在线 | 国产精品不卡视频 | 欧美精品久久久久久久久老牛影院 | 91免费官网 | 久久久精品| 97青青青国产在线播放 | 精品中文字幕在线观看 | 午夜家庭影院 | 国产在线网 | 国产片翁熄系列乱在线视频 | 日韩精品成人a在线观看 | 国产精品久久久久秋霞影视 | 国产精品99久久久久久久女警 | 一级片在线 | 欧美一区免费 | 国产中文字幕在线观看 | 欧美一级色片 | 欧美色欧美亚洲高清在线视频 |