廢話不多說了,直接給大家貼代碼了,具體代碼如下所示:
<!doctype html><html><head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Bootstrap</title> <link rel="stylesheet" href="css/bootstrap.css" rel="external nofollow" /></head><body> <!--注意:1.彈出層必須放在body里 2.彈出層里面不能再嵌套別的層 3.彈出層彈出來以后,頁面的滾動條會被覆蓋--> <div class="container"> <div class="row"> <button class="btn btn-primary" data-toggle="modal" data-target=".myModal1">彈出一個小層</button><!--data-toggle="modal"給button一個點擊事件,彈出一個模態窗口--> <button class="btn btn-primary" data-toggle="modal" data-target=".myModal2">彈出一個大層</button> </div> </div> <div class="modal fade myModal1"><!--modal,彈出層父級,fade使彈出層有一個運動過程--> <div class="modal-dialog"><!--modal-dialog,彈出層--> <div class="modal-content"><!--modal-content,彈出層內容區域--> <div class="modal-header"> <button class="close" data-dismiss="modal">×</button><!--將關閉按鈕放在標題前面可以使按鈕位于右上角--> <h4>水果攤</h4> </div><!--modal-header,彈出層頭部區域--> <div class="modal-body"> <p>蘋果葡萄香蕉柿子火龍果便宜賣了,多買優惠更多,還在等什么呢?</p> <p>蘋果葡萄香蕉柿子火龍果便宜賣了,多買優惠更多,還在等什么呢?</p> <p>蘋果葡萄香蕉柿子火龍果便宜賣了,多買優惠更多,還在等什么呢?</p> </div><!--modal-body,彈出層主體區域--> <div class="modal-footer"> <button class="btn btn-primary" data-dismiss="modal">確定</button><!--data-dismiss="modal"點擊按鈕之后可以關閉窗口--> </div><!--modal-footer,彈出層底部區域--> </div> </div> </div> <div class="modal myModal2"><!----> <div class="modal-dialog modal-lg"><!--還有modal-sm,modal-md--> <div class="modal-content"> <div class="modal-header"> <button class="close" data-dismiss="modal">×</button> <h4>水果攤</h4> </div> <div class="modal-body"> <p>蘋果葡萄香蕉柿子火龍果便宜賣了,多買優惠更多,還在等什么呢?</p> <p>蘋果葡萄香蕉柿子火龍果便宜賣了,多買優惠更多,還在等什么呢?</p> <p>蘋果葡萄香蕉柿子火龍果便宜賣了,多買優惠更多,還在等什么呢?</p> </div> <div class="modal-footer"> <button class="btn btn-primary" data-dismiss="modal">確定</button> </div> </div> </div> </div> <script src="js/jquery-2.1.0.js"></script> <script src="js/bootstrap.js"></script></body></html>

以上所述是小編給大家介紹的BootStrap 彈出層代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!
新聞熱點
疑難解答