BootStrap中動態模態框以及靜態模態框的代碼實現

來源:互聯網
上載者:User
本篇文章給大家帶來的內容是關於BootStrap中動態模態框以及靜態模態框的代碼實現,有一定的參考價值,有需要的朋友可以參考一下,希望對你有所協助。

要用bootStrap這個架構就必須要重載它的class類,也就是說class要一樣

代碼如下:

動態模態框

<!DOCTYPE html><html><head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <meta http-equiv="X-UA-Compatible" content="ie=edge">    <title>Document</title>    <link rel="stylesheet" href="bootstrap-3.3.7/css/bootstrap.css">    <script src="bootstrap-3.3.7/js/jquery.min.js"></script>    <script src="bootstrap-3.3.7/js/bootstrap.min.js"></script>    <script src="bootstrap-3.3.7/js/docs.min.js"></script></head><body>        <div>                <div>                    <div>bootstrap架構 <small>s</small>                    </div>                </div>    <!-- 動態框 --><div>    <!-- modal預設是隱藏的 -->    <div>                          <div>         <!-- 頭部關閉按鈕 -->            <div>                             <button type="button" class="close myclose" data-dismiss="modal"><span >&times</span></button>                <div class="h3 modal-title">標題部分</div>                <!-- 內容部分 -->                <div>                    <P>這是內容部分</P>                </div>                <!-- 頁尾 -->                <div>                    <button type="button" class="btn btn-primary myclose" data-dismiss="modal">Close</button>                    <button type="button" class="btn btn-warning myclose">save</button>                </div>            </div>        </div>    </div>    </div>    <a href="#" class="btn btn-success" id="show">顯示對話方塊</a>        </div></body></html><script>    $(function(){        $('#show').click(function(){            $('.modal').modal('show')        })    })</script>

靜態模態框

<!DOCTYPE html><html><head>    <meta charset="UTF-8">    <meta name="viewport" content="width=device-width, initial-scale=1.0">    <meta http-equiv="X-UA-Compatible" content="ie=edge">    <title>Document</title>    <link rel="stylesheet" href="bootstrap-3.3.7/css/bootstrap.css">    <script src="bootstrap-3.3.7/js/jquery.min.js"></script>    <script src="bootstrap-3.3.7/js/bootstrap.min.js"></script>    <script src="bootstrap-3.3.7/js/docs.min.js"></script></head><body>    <div>        <div>            <div>bootstrap架構 <small>s</small>            </div>                    <!-- 靜態模態框 官方有一個bug就是在寫靜態框的時候在按鈕上要綁定同一個class-->                <div>                    <div>                        <div>                            <button type="button" class="close myclose" data-dismiss="modal">                                <span>&times;</span>                            </button>                            <h3>Model標題</h3>                                                 </div>                     <!-- body部分 -->                     <div>                         <p>這是身體部分</p>                     </div>                     <!-- footer部分 -->                     <div>                         <button class="btn btn-info myclose" data-dismiss="modal">close</button>                         <button class="btn btn-primary myclose">save</button>                     </div>                    </div>                </div>           </div> </div>       </div>    </div></body></html><script>    $(function(){        $('.myclose').click(function(){            $('.modal-dialog').css('display','none')        })    })</script>
相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.