您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“BootStrap如何實現動態模態框及靜態模態框”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“BootStrap如何實現動態模態框及靜態模態框”這篇文章吧。
代碼如下:
1.1動態模態框
<!DOCTYPE html> <html lang="en"> <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" rel="external nofollow" rel="external nofollow" > <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 class="container"> <div class="page-header"> <div class="h3">bootstrap框架 <small>s</small> </div> </div> <!-- 動態框 --> <div class="modal"> <!-- modal默認是隱藏的 --> <div class="modal-dialog"> <div class="modal-content"> <!-- 頭部關閉按鈕 --> <div class="modal-header"> <button type="button" class="close myclose" data-dismiss="modal"><span >×</span></button> <div class="h4 modal-title">標題部分</div> <!-- 內容部分 --> <div class="modal-body"> <P>這是內容部分</P> </div> <!-- 頁腳 --> <div class="modal-footer"> <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="#" rel="external nofollow" class="btn btn-success" id="show">顯示對話框</a> </div> </body> </html> <script> $(function(){ $('#show').click(function(){ $('.modal').modal('show') }) }) </script>
1.2靜態模態框
<!DOCTYPE html> <html lang="en"> <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" rel="external nofollow" rel="external nofollow" > <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 class="container"> <div class="page-header"> <div class="h3">bootstrap框架 <small>s</small> </div> <!-- 靜態模態框 官方有一個bug就是在寫靜態框的時候在按鈕上要綁定同一個class--> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close myclose" data-dismiss="modal"> <span>×</span> </button> <h4>Model標題</h4> </div> <!-- body部分 --> <div class="modal-body"> <p>這是身體部分</p> </div> <!-- footer部分 --> <div class="modal-footer"> <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>
以上是“BootStrap如何實現動態模態框及靜態模態框”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。