欧美三区_成人在线免费观看视频_欧美极品少妇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條評論
主站蜘蛛池模板: 91久久线看在观草草青青 | 91免费在线 | 欧美精品一区二区在线观看 | 日韩国产在线 | 中文久久 | 天天爱天天操 | 久一在线视频 | 国产精品久久久久无码人妻 | 国产成人精品免费午夜 | 黄色小视频在线观看 | 国产成人综合一区二区三区 | 狠狠干伊人 | 国产精品一二区 | 2021年无线乱码播放高清完整 | 精品久久久久久中文 | 亚洲欧洲一区二区三区 | 四虎永久免费网站入口2020 | 看亚洲a级一级毛片 | 日韩在线短视频 | 黄色激情小视频 | 国内精品视频在线观看 | 亚洲视频天堂 | 久久综合久色欧美综合狠狠 | 日本不卡一区二区三区在线观看 | 久久视频在线免费观看 | 日本黄色激情 | 日出水了视频大全 | 毛片啪啪啪 | 天天搞夜夜操 | 日韩在线视频中文字幕 | 五月天激激婷婷大综合蜜芽 | 精品欧美一区二区在线看片 | 国产精品国产精品国产专区不卡 | 久久国产精品99久久久久久牛牛 | 一级高清毛片 | 午夜精品久久久久久99热7777 | 亚洲国产精品一区二区第一页 | 久久亚洲欧美日韩精品专区 | 亚洲激情一区二区 | 偷偷狠狠的日日高清完整视频 | 亚洲欧美日韩综合一区久久 |